问题
I need to use OAuth2 so I wish to develop through App Engine and Python since Google offers sample-code that should make the process easy:
https://developers.google.com/api-client-library/python/guide/aaa_oauth
https://code.google.com/p/google-api-python-client/downloads/list
It should be simple; just download the files, set the application name in app.yaml and the id/secret in the client_secrets.json. Then run/upload through Google App Engine Launcher.
However, I get the Error 400: Error: redirect_uri_mismatch. The redirect URI in the request: {localhost or appspot.com}/oauth2callback did not match a registered redirect URI.
Request Details
scope=https://www.googleapis.com/auth/plus.me
response_type=code
access_type=offline
redirect_uri={local/appspot}/oauth2callback
state={local/appspot}/:gP-pigwbwB3IBwMjafPlPToxNDE0NTA4ODYy
client_id={id-stuff}.apps.googleusercontent.com
I doubt that the problem lies in the code (since it's a working sample), but what more can it be, what am I missing?
回答1:
Go to the API Console: https://code.google.com/apis/console/
In your project, check the API Access settings and make sure that URL is one of the Redirect URIs. If not, add it.
来源:https://stackoverflow.com/questions/26612675/cant-get-google-app-engine-oauth2-sample-for-python-to-work-400-error-redi