MrT*_*tan 5 android google-api oauth-2.0 google-plus
所以我实现了谷歌加登录到我的应用程序......我的实现非常接近这里给出的例子.我和他之间的最大区别是我有更多的范围,我需要.在构建我的plusclient时,我指定以下范围:
"https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/plus.me https://www.google.com/m8/feeds https://www.googleapis.com/auth/userinfo.email"
Run Code Online (Sandbox Code Playgroud)
在我的onConnected方法的后面,我尝试从我的会话中获取一个accessstoken,以便传递到我们的服务器,在那里我们做真正的肉类和土豆工作.
GoogleAuthUtil.getToken(SplashActivity.this, mPlusClient.getAccountName(), "oauth2: https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/plus.me https://www.google.com/m8/feeds https://www.googleapis.com/auth/userinfo.email")
Run Code Online (Sandbox Code Playgroud)
这确实产生了一个accessentoken.YIPPEE!对?不.当我们尝试使用此令牌时,它似乎与我们的应用程序无关.当通过googles tokeninfo端点运行令牌时,我们得到了一些东西
{
"issued_to": "608941808256-43vtfndets79kf5hac8ieujto8837660.apps.googleusercontent.com",
"audience": "608941808256-43vtfndets79kf5hac8ieujto8837660.apps.googleusercontent.com",
"user_id": "107245641469745809180",
"scope": "https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.profile https://www.google.com/m8/feeds https://www.googleapis.com/auth/userinfo.email",
"expires_in": 3577,
"email": "redacted@email.com",
"verified_email": true,
"access_type": "online"
}
Run Code Online (Sandbox Code Playgroud)
issued_to值与我们的任何客户端ID都不匹配.根据此博客文章的最后一部分,谷歌无法将此令牌请求与我们的项目相匹配.但是,在我们的API控制台中,我确实在那里有用于android的SHA指纹,它确实用分号用分号分隔.没有拼写错误.我等了好几个小时才看出它是否是传播问题.我还添加了SHA指纹以及为我们的调试密钥库创建clientid的东西.我们是否有同样的问题,我们是否从eclipse中导出签名的apk,或者我们是否直接运行它.
这让我疯了.我不知道在哪里转过来.
例如,在打电话时
googleapis.com/plus/v1/people/me/people/visible?access_token=TOKEN_HERE&maxResults=100&pageToken=&alt=json&orderBy=best
我明白了
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured"
}
],
"code": 403,
"message": "Access Not Configured"
}
}
Run Code Online (Sandbox Code Playgroud)
因为谷歌无论出于何种原因都没有将该令牌与我的项目相关联.
到目前为止,这被认为是 google api 中的一个错误。
如果我取出“ https://www.google.com/m8/feeds ”范围,那么一切正常,并且令牌成功与我们的项目关联。如果“ https://www.google.com/m8/feeds ”作为请求范围包含在内,则 api 端的所有内容都会中断,尽管它会正确提示用户该特定权限。尽管我们在请求此范围时仍然会获得令牌,但该令牌与我们的项目无关。
| 归档时间: |
|
| 查看次数: |
6570 次 |
| 最近记录: |