I am Creating and Authorizing an OAuth Token according to this webpage: https://code.google.com/p/google-mail-oauth2-tools/wiki/OAuth2DotPyRunThrough
But I got this
For my native app, I tried dozens of different things. I finally got it to work by using "redirect_uri=http%3A%2F%2Flocalhost%3A1234" where 1234 is the port number. This has to be identical in the two requests (authorization code and the access token). Notice the use of percent encoding.
Lost 4 or 5 hours with this... use 'postmessage' as parameter value, not the real Redirect Uri...
$client->setRedirectUri('postmessage');
When you register your app at https://code.google.com/apis/console
and
make a Client ID, you get a chance to specify one or more redirect
URIs. The value of the redirect_uri
parameter on your auth URI has to
match one of them exactly.
Just in case if you're using Google+ javascript button (with web application), you have to put postmessage
instead of actual URI. It takes me almost whole day to figure out this, because Google docs doesn't clearly stand it for some reason.
Please note that the 'redirect_uri' value of the Token request need to be the same as the 'redirect_uri' value of the Authorization request.