user2463050
user2463050

Reputation: 1

Error fetching OAuth2 access token, message: 'invalid_request

I'm try to google plus api for third party log in on my web site.

I use class Google_Client method createAuthUrl to generate URI for user log in, and the page will redirect to my web site page to complete the authorization, but when I use method Google_Client.authenticate to check the result,I got following error,

Error fetching OAuth2 access token, message: 'invalid_request

so,how can I check where does the error from? maybe in session or somewhere

Upvotes: 0

Views: 4435

Answers (1)

Muukuro
Muukuro

Reputation: 31

I encountered this problem myself. As it turns out, I wasn't consistent in de construction of the client. Make sure that your redirect uri does not include the returned query string containing the authentication code!

For example this will not work:

$client->setRedirectUri('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);

REQUEST_URI will be different when the user returns from Google.

Upvotes: 2

Related Questions