适用于Android的Google API缺少Games.getGamesAuthToken

适用于Android的Google API缺少Games.getGamesAuthToken,第1张

概述适用于Android的GoogleAPI的在线reference显示了Games类的公共方法摘要,其中包括:staticPendingResult<Games.GetTokenResult>getGamesAuthToken(GoogleApiClientapiClient)但是最新版本(8.4.0)不包括这种方法.我用它来获取API:dependencies{compile'com.google

适用于Android的Google Api的在线reference显示了Games类的公共方法摘要,其中包括:

static PendingResult<Games.GetTokenResult> getGamesAuthToken(Googleapiclient apiclient)

但是最新版本(8.4.0)不包括这种方法.我用它来获取API:

dependencIEs {        compile 'com.Google.androID.gms:play-services:8.4.0'}

Games.getGamesAuthToken在哪里?

解决方法:

这实际上是一个文档问题. getGamesAuthToken()已被删除,因为它不像它需要的那样安全.

供参考,您可以阅读http://android-developers.blogspot.com/2016/01/play-games-permissions-are-changing-in.html

处理此问题的最佳方法是:

在设备上对播放器进行身份验证后:

>获取一个授权代码发送到您的后端服务器:

GetServerAuthCodeResult result =
Games.getGamesServerAuthCode(gac,clIEntID).await();
if(result.isSuccess()){
    String authCode = result.getCode();
        //将代码发送到服务器.
}

>在服务器上,交换为令牌收到的身份验证代码
将RPC发送到https://www.GoogleAPIs.com/oauth2/v4/token以交换访问令牌的身份验证代码.
您必须提供服务器客户端ID,服务器客户端密钥(在创建服务器客户端ID时在Developer Console中列出)和身份验证代码.
点击此处查看更多详情:https://developers.google.com/identity/protocols/OAuth2WebServer?utm_campaign=play games_discussion_permissions_012316&utm_source=anddev&utm_medium=blog#handlingresponse.
>获得访问令牌后,将使用以下方式检索玩家的ID:
www.GoogleAPIs.com/games/v1/applications/\u0026lt;app_ID\u0026gt;/verify/使用访问令牌.
在标头中传递身份验证令牌,如下所示:
“授权:OAuth”

响应值将包含用户的玩家ID.这是用于此用户的正确玩家ID.
此访问令牌可用于根据需要进行其他服务器到服务器调用.

总结

以上是内存溢出为你收集整理的适用于Android的Google API缺少Games.getGamesAuthToken全部内容,希望文章能够帮你解决适用于Android的Google API缺少Games.getGamesAuthToken所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1096952.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存