user-management
user-management copied to clipboard
RESTFUL
Hi I configure like Chapter 6. RESTful Web Services of Yii2 Application Development Cookbook Third Edition book, and work fine.
But when I changed tu user-managment I recive:
"name": "Unauthorized", "message": "Your request was made with invalid credentials.", "code": 0, "status": 401, "type": "yii\web\UnauthorizedHttpException"
If I configure at database level username = auth_key work OK but no validate the password.
Can you helpme?
me too! please help us!
@rizrob66 I think you need to use HttpBearerAuth instead default FormLogin authentication
@colesnic89 Thanks for your tips
I did it in my Controller:
public function behaviors() { $behaviors = parent::behaviors(); //$behaviors['authenticator']['only'] = ['create', 'update', 'delete']; $behaviors['authenticator']['authMethods'] = [ HttpBearerAuth::class, ]; return $behaviors; }
but the answer is always
"name": "Unauthorized",
If I remove comment from $behaviors['authenticator']['only'] = ['create', 'update', 'delete'];
index works fine.
I did the tests with Postman Bearer Authentication usesing the token in the auth_key.
Is it correct?
@rizrob66 It is hard to understand what happened. I always use XDebug in cases like this.