Youtube Data API v3无法启动可恢复上载


Youtube Data API v3 Failed to start the resumable upload

截至今天上午,我在尝试使用服务帐户和密钥上传视频时遇到此错误,昨天下午6点左右成功。

我试过将可恢复选项设置为true和false,但都没有用。

这是我的代码

$client = new Google_Client();
$client->setClientId($OAUTH2_CLIENT_ID);
$key = file_get_contents($KEY_FILE);
$client->setAssertionCredentials(new Google_AssertionCredentials(
    $SERVICE_ACCOUNT_NAME,
    array('https://www.googleapis.com/auth/youtube'),
    $key)
);

$client->setClientSecret($OAUTH2_CLIENT_SECRET);
$redirect = filter_var('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'],
    FILTER_SANITIZE_URL);
//$client->setRedirectUri($redirect);
$htmlBody = '';
// YouTube object used to make all API requests.
$youtube = new Google_YoutubeService($client);

我从这里得到了一个有效的承载签名,但当我开始上传时,当将不可恢复标志设置为false时,我会收到以下错误:

$media = new Google_MediaFileUpload('video/mp4', null, true, $chunkSizeBytes);
"error": {
  "errors": [
   {
    "domain": "youtube.header",
    "reason": "youtubeSignupRequired",
    "message": "Unauthorized",
    "locationType": "header",
    "location": "Authorization"
   }
  ],
  "code": 401,
  "message": "Unauthorized"
 }

我没有设置引用凭据的访问令牌。请确保您设置了访问令牌!