【问题标题】:Authenticate method is deprecated in google drive api (PHP)身份验证方法在 google drive api (PHP) 中已弃用
【发布时间】:2019-08-07 19:19:32
【问题描述】:

我之前使用过 google drive api v3 没有任何问题,现在经过很长时间我再次使用它来使用访问令牌对用户进行身份验证,但是当我调用 google drive 客户端的身份验证方法时,它指出该方法已被弃用,我也是'已经观察到谷歌改变了许多其他功能。

$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>

因为身份验证给出空响应,所以它不允许设置访问令牌并给出错误 json_decode() 期望参数 1 是字符串,给定数组。

【问题讨论】:

    标签: php google-drive-api


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多