适用于Google云端硬盘的OAuth2客户端应用程序登录

时间:2012-05-24 15:17:27

标签: oauth-2.0 google-drive-api

我正在尝试按照https://developers.google.com/accounts/docs/OAuth2UserAgent上的说明操作,以便使用google云端硬盘应用程序登录。我拥有的OAuth API信息是:

Client ID for web applications
Client ID:          444837786259.apps.googleusercontent.com
Email address:      444837786259@developer.gserviceaccount.com
Client secret:      [snip]
Redirect URIs:      http://meridiandigital.co.uk/drivecrypt/
                    http://apate.meridiandigital.net/drivecrypt/
JavaScript origins: http://meridiandigital.co.uk
                    http://apate.meridiandigital.net

Client ID for Drive SDK
Client ID:          444837786259-8vsffg8dnl2s8hvoeiu8v0laqaqc5p2p.apps.googleusercontent.com
Client secret:      [snip]

在我的客户端,我检测到我没有有效令牌并将用户发送到以下URL的情况

 https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/drive.file+https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile&response_type=token&redirect_uri=http://apate.meridiandigital.net/drivecrypt/&client_id=444837786259-8vsffg8dnl2s8hvoeiu8v0laqaqc5p2p.apps.googleusercontent.com

我从Google收到以下错误消息:

The redirect URI in the request: http://apate.meridiandigital.net/drivecrypt/ did not match a registered redirect URI

from_login=1
scope=https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/drive.file
response_type=token
access_type=online
redirect_uri=http://apate.meridiandigital.net/drivecrypt/
approval_prompt=auto
as=488fe0f410123e7c
pli=1
client_id=444837786259-8vsffg8dnl2s8hvoeiu8v0laqaqc5p2p.apps.googleusercontent.com
authuser=0
hl=en-GB

任何想法我做错了什么?

1 个答案:

答案 0 :(得分:1)

您需要使用API​​控制台生成的Web应用程序的客户端ID(并将其用于Drive SDK应用程序)。

引发错误的原因是没有为客户端ID 444837786259-8vsffg8dnl2s8hvoeiu8v0laqaqc5p2p.apps.googleusercontent.com注册重定向URI。如果您尝试使用444837786259.apps.googleusercontent.com,它应该有效。

相关问题