FriendsOfSymfony / FOSOAuthServerBundle

A server side OAuth2 Bundle for Symfony
1.09k stars 450 forks source link

User is null even after authentication #595

Open suchith6982 opened 6 years ago

suchith6982 commented 6 years ago

Hi,

I'm using FOSOAuthServerBundle and FOSUserBundle. I can successfully get the Auth code and the Auth token from the code. But even after getting the auth token, the user is null when trying to use $this->getUser(). In access token table, the user_id is also null. I'm using authorization_code as the grant_type. I'm using two databases in my project. The users table is in one database and the access_token, client, refresh_token tables are in a different database. whenever I try to use $this->getUser() its null.

jllaurado commented 5 years ago

Just to be discard things... have you tried to check if on the oauth server side your user is authenticated?

If already is authenticated, I suggest to var_dump on the league/oauth2-client/src/Provider/AbstractProvider.php lines 634...636 to see what you are receiving: try { $response = $this->getResponse($request); } catch (BadResponseException $e) { $response = $e->getResponse(); var_dump($response->getBody()->getContents()); }

That way you'll be able to see if the problem resides on the client or the server.