在添加范围"https://www.googleapis.com/auth/calendar.readonly“后,将导致以下错误。
$gClient = new Google_Client();
$gClient->setApplicationName('Login');
$gClient->setClientId($google_client_id);
$gClient->setClientSecret($google_client_secret);
$gClient->setRedirectUri($google_redirect_url);
$gClient->setScopes(array('https://www.googleapis.com/auth/calendar.readonly'));收到的错误是
致命错误:异常“Google_ServiceException”和消息“错误调用GET https://www.googleapis.com/oauth2/v2/userinfo:(401)请求缺少所需的身份验证凭据。预期的OAuth 2访问令牌、登录cookie或其他有效的身份验证凭据。请参见https://developers.google.com/identity/sign-in/web/devconsole-project。”在C:\xampp\htdocs\bvs\online-payment\src\io\Google_REST.php:66堆栈跟踪中:#0 C:\xampp\htdocs\bvs\online-payment\src\io\Google_REST.php(36):Google_REST::decodeHttpResponse(Object(Google_HttpRequest)) #1 C:\xampp\htdocs\bvs\online-payment\src\service\Google_ServiceResource.php(177):Google_REST::execute(Object(Google_HttpRequest)) #2 C:\xampp\htdocs\bvs\online-payment\src\contrib\Google_Oauth2Service.php(37):谷歌_服务资源->__call(‘get’)数组) #3 C:\xampp\htdocs\bvs\online-payment\login.php(49):Google_UserinfoServiceResource->get() #4 {main}抛入第66行的C:\xampp\htdocs\bvs\online-payment\src\io\Google_REST.php中。
发布于 2019-12-04 09:39:56
官方的Google 文档将范围设置的语法指定为:
$gClient->setScopes(Google_Service_Calendar::CALENDAR_READONLY);https://stackoverflow.com/questions/59171913
复制相似问题