thephpleague / oauth2-server

A spec compliant, secure by default PHP OAuth 2.0 Server
https://oauth2.thephpleague.com
MIT License
6.51k stars 1.12k forks source link

Error: invalid client and client authentication failed with status code 401 Unauthorized when requesting access_token #1234

Closed alessandrog22 closed 3 years ago

alessandrog22 commented 3 years ago

I am using this library and the client one for a project and, after the sign in/sign up and the authorization of the scopes, following the Auth Code Grant flow, I have to request an access_token that lets the user call the apis. But after some debug I reach this error from the response. I hope someone can help me. Senzanome

Sephster commented 3 years ago

Apologies for the delay in replying. With the auth code grant, usually this error is thrown because your redirect URI does not match any of the redirect URIs the client was registered with. In your case I can see you are using a redirect URI of localhost so this must be registered with the client.

If this is not the case, the client credentials provided will be failing. You should check both of these in your request to determine which scenario might be causing this.

Hope this helps and good luck with the fix!