【问题标题】:Google App Engine to Calendar AuthenticationGoogle App Engine 到日历身份验证
【发布时间】:2013-07-02 02:19:28
【问题描述】:

我是 App Engine 的新手,正在尝试编写一个应用程序,该应用程序将访问 Google 日历以获取当前时间的任何事件的详细信息。我正在努力了解身份验证应该如何工作以允许访问日历。我相信 OAuth2 是首选的身份验证选项,因此我有一个 client_secrets.json 文件,其中包含来自我单独创建的 API 访问项目的 ClientID 和 Client Secret:

{
"web":{
"auth_uri":"https://accounts.google.com/o/oauth2/auth",
"client_secret":"xxxxxxx",
"token_uri":"https://accounts.google.com/o/oauth2/token",
"client_email":"xxxxxxx@developer.gserviceaccount.com",
"redirect_uris":["https://myapp.appspot.com/oauth2callback"],
"client_x509_cert_url":"https://www.googleapis.com/robot/v1/metadata/x509/xxxxxxx@developer.gserviceaccount.com",
"client_id":"123456789.apps.googleusercontent.com",
"auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs",
"javascript_origins":["https://myapp.appspot.com"]
}
}

这是使用“下载 JSON”选项从 API Access 项目直接导出的。当我部署我的应用引擎应用程序时出现错误:

Error: redirect_uri_mismatch
The redirect URI in the request: http://myapp.appspot.com/oauth2callback did not match a registered redirect URI
Learn more
Request Details
scope=https://www.googleapis.com/auth/calendar
response_type=code
access_type=offline
redirect_uri=https://myapp.appspot.com/oauth2callback
display=page
client_id=123456789.apps.googleusercontent.com

对我来说一切都很好,所以我不确定错误告诉我什么。我是否需要以某种方式将 App Engine 应用程序链接到 API Access 项目。我是否缺少其他基本内容。

如果有任何其他信息可以帮助您了解设置,请告诉我。我想保持帖子小。

【问题讨论】:

    标签: google-app-engine oauth-2.0 google-calendar-api


    【解决方案1】:

    有一条评论here说:

    当您创建凭据时,您可能表明 您创建的客户端凭据用于 Web 应用程序 而不是已安装的应用程序。当你这样做时,你输入一个 该组凭据的重定向 URI。您使用的样本是 对已安装的应用程序使用带外重定向 URI 与您指定的不匹配,因此它不允许您 竞争身份验证流程。这是为了保护您免受恶意 使用您的客户端凭据。打开 API 控制台并创建一个新的 “已安装的应用程序”而不是“Web 应用程序”的客户端 ID 这应该可以。

    您是否设置了 Web 应用程序或已安装的应用程序?

    【讨论】:

    • 我正在尝试设置在 Google App Engine 上运行的网络应用程序。 Web 应用程序还有问题吗?谢谢詹姆斯
    猜你喜欢
    • 2014-04-30
    • 1970-01-01
    • 2011-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-02
    • 2011-02-23
    相关资源
    最近更新 更多