简体   繁体   中英

Authenticate method is deprecated in google drive api (PHP)

I've used google drive api v3 earlier without any issue now after long time I'm using it again to authenticate user with access token but when I call authenticate method of google drive client it states this method is deprecated, also I've observed google has changed many other features.

$file = 'credentials.json';
$client = new Google_Client();
$client->setScopes([
    'https://www.googleapis.com/auth/drive',
    'https://www.googleapis.com/auth/drive.metadata',
    'https://www.googleapis.com/auth/drive.file',
    ]);
$client->setAuthConfig($file);
if (isset($_REQUEST['code'])){
    $accessToken = $client->authenticate($_GET['code']);
    $client->setAccessToken(json_decode($accessToken, true));
    return $client;
}
$authUrl = $client->createAuthUrl();
<a href="<?php echo $authUrl; ?>">Login</a>

as authenticate is giving null response so its not letting to set access token and giving error json_decode() expects parameter 1 to be string, array given.

对于寻找新命令的任何人,请改用:

$accessToken = $client->fetchAccessTokenWithAuthCode($_GET['code']);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM