您好,我尝试在不使用Google+ API的情况下实现Google登录,但遇到错误。我不了解此错误或出现此错误的原因。我正在遵循指南here。
代码:
<?php
require_once (__DIR__.'../google-api-php-client-2.2.2/vendor/autoload.php');
session_start();
$client = new Google_Client();
$client->setAuthConfigFile('client/client_secrets.json');
$redirect_uri = 'myRedirectUri';
$client->setRedirectUri('myRedirectUri2');
$client->addScope('profile');
$client->setIncludeGrantedScopes(true);
if(!isset($_GET['code'])){
$auth_url = $client->createAuthUrl();
header('Location: '.filter_var($auth_url,FILTER_SANITIZE_URL));
}
else{
$client->authenticate($_GET['code']);
$_SESSION['access_token'] = $client->getAccessToken();
header('Location: '.filter_var($redirect_uri,FILTER_SANITIZE_URL));
}
?>
这是我遇到的错误的图片: