Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RESTFUL #190

Open
oscarsantook opened this issue Mar 31, 2018 · 4 comments
Open

RESTFUL #190

oscarsantook opened this issue Mar 31, 2018 · 4 comments

Comments

@oscarsantook
Copy link

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?

@rizrob66
Copy link

me too! please help us!

@colesnic89
Copy link

@rizrob66 I think you need to use HttpBearerAuth instead default FormLogin authentication

@rizrob66
Copy link

@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?

@colesnic89
Copy link

colesnic89 commented Oct 23, 2021

@rizrob66 It is hard to understand what happened. I always use XDebug in cases like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants