所以,我從我的使用驗證ID令牌使用www.googleapis.com和谷歌API的PHP客戶端
GoogleSignInAccount acct = result.getSignInAccount();
String idToken = acct.getIdToken();
Android應用獲取的令牌標識。如果我試圖驗證使用https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=idToken
令牌然後它會成功;我的意思是googleapis.com會返回類似:
{
iss: "https://accounts.google.com",
aud: "12312331-hjs13hbf0j1ge08s7lvepiupiljuokce.apps.googleusercontent.com",
sub: "23432432",
email_verified: "true",
azp: "12312331-nvi4gh28jekfm3e48ofqeh1c5rof2rsa.apps.googleusercontent.com",
email: "[email protected]",
iat: "123213123",
exp: "123213123",
name: "Me Miow",
picture: "https://lh5.googleusercontent.com/-XXXX/AAAAAAAAAAI/XXXX/XXXX/s96-c/photo.jpg",
given_name: "Me",
family_name: "Miow",
locale: "en",
alg: "RS256",
kid: "849996986ecf01a6c8xxxxxxx"
}
但如果使用圖書館https://github.com/google/google-api-php-client和運行idtoken.php碼= idToken庫從谷歌\ apiclient \例子,它將返回
Fatal error: Uncaught InvalidArgumentException: Invalid token format in /home/meowww/public_html/meniti/vendor/google/apiclient/src/Google/Client.php:423 Stack trace: #0 /home/meowww/public_html/meniti/idtoken.php(65): Google_Client->setAccessToken(Array) #1 {main} thrown in /home/meowww/public_html/meniti/vendor/google/apiclient/src/Google/Client.php on line 423
爲什麼google-api-php-client會顯示錯誤?
感謝您的解釋! – imin
很高興幫助! – trajchevska