【发布时间】:2020-09-19 11:46:44
【问题描述】:
使用 Google OAuth 登录时出现错误。使用谷歌登录的桌面网站或移动浏览器使用没有问题。但是用户想在设备上安装的网站的移动浏览器和 PWA 上登录,然后在点击谷歌登录后移动浏览器重定向到 PWA。 PWA 从 GET 获取令牌,但给出“无效令牌格式”错误。
“未捕获的 InvalidArgumentException:/vendor/google/apiclient/src/Google/Client.php:449 中的令牌格式无效”
从谷歌返回的 URL 是:
https://example.com/google/?code=4/tokenxxx&scope=email个人资料https://www.googleapis.com/auth/userinfo.emailhttps://www.googleapis.com/auth/userinfo.profileopenid&authuser=1&hd=xx.com&prompt=none
$accessToken = $this->gClient->fetchAccessTokenWithAuthCode( trim( $_GET['code'] ) );
$this->gClient->setAccessToken( $accessToken ); // error line
桌面使用没有错误,也没有移动浏览器重定向到 PWA。
我需要一些想法。
编辑: $this->gClient->fetchAccessTokenWithAuthCode( trim( $_GET['code'] ) ) 函数返回“invalid_grant”错误。
【问题讨论】:
标签: php authentication oauth progressive-web-apps manifest