在服务器上获取Google Play游戏玩家ID [英] Getting Google Play Games player ID on server
本文介绍了在服务器上获取Google Play游戏玩家ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Play游戏权限为在2016年发生的变化解释了如何在服务器上获取Play游戏玩家ID。我可以在服务器上成功获取访问令牌,但我无法完成此步骤:
The post Play Games Permissions are changing in 2016 explains how to get the Play Games player ID on a server. I can successfully get the access token on the server, but I can't get this step to work:
- 获得访问令牌后,请使用该
访问令牌调用www.googleapis.com/games/v1/applications/yourAppId/verify/。按如下方式在标头中传递身份验证令牌:
授权:OAuth响应值将包含
用户的玩家ID。
我试图在Google App Engine中使用:
I'm trying to do that in Google App Engine using:
accessToken = ...; //-- I can always get this successfully
URL url = new URL(String.format("https://www.googleapis.com/games/v1/applications/%s/verify/",myAppId));
HTTPRequest request = new HTTPRequest(url, HTTPMethod.GET);
HTTPHeader httpHeader = new HTTPHeader("Authorization: OAuth",accessToken);
request.addHeader(httpHeader);
HTTPResponse httpResponse = urlFetchService.fetch(request);
响应总是返回代码401.我该如何调试?
The response always return code 401. How can I debug?
推荐答案
问题出在header上,应该像这样添加:
The problem was with the header, it should be added like this:
HTTPHeader httpHeader = new HTTPHeader("Authorization","OAuth " + accessToken);
这篇关于在服务器上获取Google Play游戏玩家ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文