【问题标题】:Getting Google Play Games player ID on server在服务器上获取 Google Play 游戏玩家 ID
【发布时间】:2016-04-08 23:40:42
【问题描述】:

Play Games Permissions are changing in 2016 帖子解释了如何在服务器上获取 Play 游戏玩家 ID。我可以成功获取服务器上的访问令牌,但是我无法让这一步工作:

  1. 获得访问令牌后,使用该令牌调用 www.googleapis.com/games/v1/applications/yourAppId/verify/ 访问令牌。在标头中传递身份验证令牌,如下所示: “授权:OAuth”响应值将包含 用户的玩家 ID。

我正在尝试在 Google App Engine 中使用:

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。我该如何调试?

【问题讨论】:

    标签: android google-app-engine google-play-games


    【解决方案1】:

    identical issue (sort of) 表示您必须以不同方式设置标题(不使用 HttpHeader)。

    httppost.setHeader("授权", "承载"+accessToken);

    希望这可以解决您的问题。

    【讨论】:

    • 感谢@adjuremods,您部分正确,因为我在标题中包含了“:”,并且“OAuth”应该是标题值的一部分,而不是标题名称。
    【解决方案2】:

    问题出在标题上,应该这样添加:

    HTTPHeader httpHeader = new HTTPHeader("Authorization","OAuth " + accessToken);
    

    【讨论】:

      猜你喜欢
      • 2015-05-31
      • 1970-01-01
      • 2016-07-10
      • 1970-01-01
      • 1970-01-01
      • 2014-06-08
      • 2014-01-11
      • 2018-11-13
      • 2014-01-16
      相关资源
      最近更新 更多