在服务器上获取 Google Play Games 玩家 ID
Getting Google Play Games player ID on server
post Play Games Permissions are changing in 2016 解释了如何在服务器上获取 Play 游戏玩家 ID。我可以在服务器上成功获取访问令牌,但是我无法使这一步起作用:
- Once you have the access token, call www.googleapis.com/games/v1/applications/yourAppId/verify/ using that
access token. Pass the auth token in a header as follows:
“Authorization: OAuth ” The response value will contain
the player ID for the user.
我尝试在 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);
响应总是return代码401。我该如何调试?
identical issue (sort of) 表示您必须以不同方式设置 header(不使用 HttpHeader
)。
httppost.setHeader("Authorization", "Bearer "+accessToken);
希望这可以解决您的问题。
问题出在header,应该这样添加:
HTTPHeader httpHeader = new HTTPHeader("Authorization","OAuth " + accessToken);
post Play Games Permissions are changing in 2016 解释了如何在服务器上获取 Play 游戏玩家 ID。我可以在服务器上成功获取访问令牌,但是我无法使这一步起作用:
- Once you have the access token, call www.googleapis.com/games/v1/applications/yourAppId/verify/ using that access token. Pass the auth token in a header as follows: “Authorization: OAuth ” The response value will contain the player ID for the user.
我尝试在 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);
响应总是return代码401。我该如何调试?
identical issue (sort of) 表示您必须以不同方式设置 header(不使用 HttpHeader
)。
httppost.setHeader("Authorization", "Bearer "+accessToken);
希望这可以解决您的问题。
问题出在header,应该这样添加:
HTTPHeader httpHeader = new HTTPHeader("Authorization","OAuth " + accessToken);