Skip to main content
 首页 » 编程设计

python之无法让 Google App Engine OAuth2-sample(适用于 Python)工作之400 错误 : redirect_uri_mismatch

2024年10月25日34birdshome

<分区>

我需要使用 OAuth2,所以我希望通过 App Engine 和 Python 进行开发,因为 Google 提供了示例代码,应该可以简化该过程:

https://developers.google.com/api-client-library/python/guide/aaa_oauth

https://code.google.com/p/google-api-python-client/downloads/list

应该很简单;只需下载文件,在 app.yaml 中设置应用程序名称,在 client_secrets.json 中设置 id/secret。然后通过 Google App Engine Launcher 运行/上传。

但是,我得到了错误 400:错误:redirect_uri_mismatch。 请求中的重定向 URI:{localhost 或 appspot.com}/oauth2callback 与已注册的重定向 URI 不匹配。

请求详情

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 

我怀疑问题出在代码上(因为它是一个工作示例),但它还能是什么,我错过了什么?