文档再次让我转圈
游戏登录文档建议使用常规的Google登录过程:
https://developers.google.com/games/services/android/signin
指向使用 ID令牌进行服务器端用户身份验证:
https://developers.google.com/identity/sign-in/android/backend-auth
但是,似乎没有办法获得与该可验证ID令牌匹配的游戏玩家ID ,这意味着最终我们无法确定进行了以下操作的游戏玩家的真实性:在。
我还发现了一个verify呼叫,该呼叫似乎旨在获取游戏玩家ID,但被锁定在访问令牌后面,该令牌会在登录后强制执行其他操作,以及更复杂的客户端与服务器之间的交换,通常是不可取的,因为我们的目标不是代表用户进行任何Google通话。
奇怪的是,没有直接的方法可以通过Google再次查看Games ID的真实性。是否有另一个游戏ID身份验证程序,也许我只是想念?
答案 0 :(得分:0)
奇怪的是,没有直接的方法可以通过Google再次查看Games ID的真实性。是否有另一个游戏ID身份验证程序,也许我只是想念?
有,并且您在问题中提到了它:使用访问令牌。
将其与Google_Service_Games ang关联起来,即可获得相同的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();