文档,再一次让我兜圈子
游戏登录文档建议使用正常的 Google 登录程序:
https://developers.google.com/games/services/android/signin
这指向使用 ID token 进行服务器端用户身份验证:
https://developers.google.com/identity/sign-in/android/backend-auth
但是,似乎没有办法获得与此可验证 ID token 匹配的 Games 玩家 ID,这意味着最终我们无法确定进行签名的 Games 玩家的真实性-在。
我还找到了一个 verify似乎旨在获取游戏玩家 ID 的调用,但它被锁定在 访问 token 后面,这将在登录时强制执行额外的权限,以及更复杂的客户端-服务器交换,并且在一般情况下,因为我们不打算代表用户进行任何 Google 调用。
奇怪的是,没有一种直接的方法可以通过 Google 检查游戏 ID 的真实性。游戏 ID 是否还有其他身份验证程序,我可能只是想念它?
最佳答案
It is bizarre that there isn't a direct way to check the Games id authenticity back with Google. Is there another authentication procedure for Games id, that I'm just missing maybe?
有,而且您在问题中提到过:使用访问 token 。
将其与 Google_Service_Games 联系起来,您将获得相同的 ID。 (以 g 开头;openID 仅为数字)
$googleClient = new \Google_Client();
$googleClient->setClientId(GOOGLE_OAUTH_CLIENT_ID);
$googleClient->setClientSecret(GOOGLE_OAUTH_CLIENT_SECRET);
$googleClient->setRedirectUri('postmessage');
$googleClient->setScopes('googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/games https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email');
$googleToken = json_encode([
'access_token' => $accessToken,
'token_type' => '',
'expires_in' => 1800,
'id_token' => '',
'refresh_token' => $refreshToken,
'created' => time()
]);
$googleClient->setAccessToken($googleToken);
$gamesService = new \Google_Service_Games($googleClient);
$me = $gamesService->players->get('me');
$me = $me->toSimpleObject();
关于android - 如何在后端服务器上验证 Google 游戏播放器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56154858/