Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python oauth2client.contrib.flask_util库_Python_Google App Engine_Oauth_Google Authentication - Fatal编程技术网

Python oauth2client.contrib.flask_util库

Python oauth2client.contrib.flask_util库,python,google-app-engine,oauth,google-authentication,Python,Google App Engine,Oauth,Google Authentication,我对oauth2client.contrib.flask\u util有问题 我创建app.config: app.config['GOOGLE_OAUTH2_CLIENT_SECRETS_FILE'] = 'web_aplication.json' oauth2 = UserOAuth2(app) 并使用@oauth2.required强制授权 @app.route('/example') @oauth2.required def example(): return 'all do

我对oauth2client.contrib.flask\u util有问题

我创建app.config:

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

oauth2 = UserOAuth2(app)
并使用@oauth2.required强制授权

@app.route('/example')
@oauth2.required
def example():
    return 'all done'
但当我上网时,我有一个

错误400错误:重定向uri与请求中的重定向uri不匹配,与OAuth客户端授权的重定向uri不匹配

当然,我在console.cloud.google.com中添加了
http[s]://[your-app-url]/oauth2callback


因此,我的问题是如何路由错误的
http://127.0.0.1:5000/oauth2callback
https://[my_url]/oauth2callback

我还没有完全理解你的问题。以下是我的假设:

您正在本地计算机上进行测试。 在本例中,您确实访问了
http://127.0.0.1:5000/example
,并将其重定向到
http://127.0.0.1:5000/oauth2callback
这绝对正确。您应该添加
http://127.0.0.1:5000/oauth2callback
到您的谷歌云控制台进行测试

您正在运行生产服务器。 在这种情况下,您的服务器配置一定有问题,即的
url\u无法生成正确的URI


仅供参考,
重定向uri
是由

生成的,我还没有完全理解您的问题。以下是我的假设:

您正在本地计算机上进行测试。 在本例中,您确实访问了
http://127.0.0.1:5000/example
,并将其重定向到
http://127.0.0.1:5000/oauth2callback
这绝对正确。您应该添加
http://127.0.0.1:5000/oauth2callback
到您的谷歌云控制台进行测试

您正在运行生产服务器。 在这种情况下,您的服务器配置一定有问题,即
url\u无法生成正确的URI

请参考,
重定向uri