TheZnajomy
TheZnajomy

Reputation: 1

oauth2client.contrib.flask_util library

I have a problem with oauth2client.contrib.flask_util

I create app.config:

app.config['GOOGLE_OAUTH2_CLIENT_SECRETS_FILE'] = 'web_aplication.json'

oauth2 = UserOAuth2(app)

and enforced authorization with @oauth2.required

@app.route('/example')
@oauth2.required
def example():
    return 'all done'

But when I go to web I have a

Error 400 Error: redirect_uri_mismatch The redirect URI in the request, http://127.0.0.1:5000/oauth2callback, does not match the ones authorized for the OAuth client.

Of course I added http[s]://[your-app-url]/oauth2callback to console.cloud.google.com

So my question is how can I route a wrong http://127.0.0.1:5000/oauth2callback to https://[my_url]/oauth2callback

Upvotes: 0

Views: 120

Answers (1)

lepture
lepture

Reputation: 2422

I haven't fully understood your question. Here are my assumptions:

You are testing on your local machine.

In this case, you did visit http://127.0.0.1:5000/example, and it redirected to http://127.0.0.1:5000/oauth2callback which is absolutely correct. You should add http://127.0.0.1:5000/oauth2callback to your Google Cloud console for testing.

You are running a production server.

In this case, there must be something wrong with your server configuration, that url_for can't make a correct URI.

For your information, the redirect_uri is generated by https://github.com/google/oauth2client/blob/master/oauth2client/contrib/flask_util.py#L348

Upvotes: 2

Related Questions