【问题标题】:Google Drive API 401 when trying to download a file尝试下载文件时出现 Google Drive API 401
【发布时间】:2013-01-02 22:15:53
【问题描述】:

我正在使用google-api-php-client 来获取我的 Google 云端硬盘上文档的 URL。当我将 URL 粘贴到浏览器中时,该 URL 可以正常工作,我可以下载该文件。

但是,在我的 PHP 应用程序中,我总是得到 401。这是我的代码:

private function _get_document_contents($url)
{
    // prepare opts
    $opts = array(
        'http' => array(
            'method' => 'GET',
            'header' => "Gdata-version: 3.0\r\nAuthorization: Bearer " . $this->_token . "\r\n"
        )
    );

    // get the doc
    return file_get_contents($url . '&exportFormat=html&format=html', false, stream_context_create($opts));
}

我尝试将 Bearer 更改为 OAuth(这是 OAuth 2.0 游乐场使用的),但都失败了。

有什么想法吗?

【问题讨论】:

    标签: oauth-2.0 google-drive-api google-oauth google-api-php-client


    【解决方案1】:

    啊,问题似乎是我使用的是旧的 Google Docs API,应该迁移到 Google Drive SDK。哦!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-20
      • 2022-11-15
      • 1970-01-01
      • 2020-06-08
      • 2021-03-23
      • 2021-12-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多