2013-06-05 114 views
0

我是App Engine的新手,并且正在尝试编写一个应用程序,该应用程序将访问Google日历以获取当前任何事件的详细信息。我正在努力查看身份验证如何工作以允许访问日历。我相信了OAuth2是首选的身份验证选项,所以我有一个从API Access项目我已分别创建了ClientID的和客户端秘密的client_secrets.json文件:使用Google App Engine以日历身份验证

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

这是从API访问项目的直接出口'下载JSON'选项。当我部署我的App Engine应用程序我得到一个错误:

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项目。我是否缺少别的根本。

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

回答

1

有,说评论here

When you created your credentials, you probably indicated that the client credentials you were creating were for a web application instead of an installed application. When you do that, you enter a Redirect URI for that set of credentials. The sample you are using is using the out of band Redirect URI for installed applications which does not match the one you specified, so it will not allow you to compete the authentication flow. This is to protect you from malicious use of your client credentials. Open the APIs console and create a new client ID for "installed applications" instead of "web applications" and this should work.

你建立一个Web应用程序或安装的应用程序?

+0

我正在尝试设置运行在Google App Engine上的Web应用程序。 Web应用程序仍然有问题吗?谢谢詹姆斯 – James