oauth2-bundle
oauth2-bundle copied to clipboard
unsupported_grant_type
Hi colleagues, Actually I couldn't find any information about correct URL for oauth server. I just expected to receive the "code" or something for getting a token. Can you say what I'm doing wrong?

The routes for the endpoints are defined here: https://github.com/trikoder/oauth2-bundle/blob/v3.x/Resources/config/routes.xml
I'm not sure what are you trying to do - a client credentials grant request or an authorization code grant request?
Client credentials test example: https://github.com/trikoder/oauth2-bundle/blob/v3.x/Tests/Acceptance/TokenEndpointTest.php#L37
Auth code grant test example: https://github.com/trikoder/oauth2-bundle/blob/v3.x/Tests/Acceptance/AuthorizationEndpointTest.php#L47 and then https://github.com/trikoder/oauth2-bundle/blob/v3.x/Tests/Acceptance/TokenEndpointTest.php#L137
I'm not sure what are you trying to do - a client credentials grant request or an authorization code grant request?
I just want to authenticate a user (like we are doing via FB or Google). So if I right understand i need first send a GET request with some parameters: request_uri, scope, app id and secret like here:
Then I expect to receive the code.
Thanks for the links. I will check it!
@X-Coder264 Am I right understand, that with this request I should receive a code from a server?

You can find the auth code grant documentation here: https://github.com/trikoder/oauth2-bundle/pull/177/files
The endpoint URL depends on how you've imported the routes.xml from the bundle in your project (with or without some prefix for example).
You can find further documentation about that grant type on the web, for example: https://developer.okta.com/blog/2018/04/10/oauth-authorization-code-grant-type
@X-Coder264
Well, almost get it, but have an error:
HTTP/1.1 401 Unauthorized returned for "http://127.0.0.1:8001/token".


So, I resolved this with change in http request:
'grant_type' => 'authorization_code',
on
'grant_type' => 'client_credentials',
And it works. I have the token.
Have no idea why, because on tests is 'grant_type' => 'authorization_code',
Even if in database table:oauth2_client I change grant_type to authorization_code it still doesn't work. Only client_credentials
Can I ask you @X-Coder264 Where to set a user fields for access_token and why I have scope there 'read' when I have 'user.view'.

When I set $event->setUser() in AuthorizationCodeListener it works only for authorization_code table. But where for access_token?