Php 谷歌YouTube API——401关于删除请求

Php 谷歌YouTube API——401关于删除请求,php,google-api,youtube-api,google-api-php-client,Php,Google Api,Youtube Api,Google Api Php Client,我试图通过YouTube API删除视频,并获得401状态码,告诉我需要登录: YouTube delete exception: Client error: `DELETE https://www.googleapis.com/youtube/v3/videos?id=qHwE11JqiW8&onBehalfOfContentOwner=SNIP&prettyPrint=1` resulted in a `401 Unauthorized` response: { "error

我试图通过YouTube API删除视频,并获得401状态码,告诉我需要登录:

YouTube delete exception: Client error: `DELETE https://www.googleapis.com/youtube/v3/videos?id=qHwE11JqiW8&onBehalfOfContentOwner=SNIP&prettyPrint=1` resulted in a `401 Unauthorized` response: { "error": { "errors": [ { "domain": "global", "reason": "required", "message": "Login Required", (truncated...)
下面是创建我的Google客户端对象的代码:

    $google_client = new Google_Client();
    $google_client->setHttpClient($this->httpClient);
    $google_client->addScope([\Google_Service_YouTube::YOUTUBE, \Google_Service_YouTubePartner::YOUTUBEPARTNER]);
    // This ensures the token is refreshed automatically for the life of the
    // client.
    $google_client->setAccessType('offline');
    if (!empty($google_auth_config['client_id_json'])) {
      $decoder = new JsonDecode(TRUE);
      $google_client->setAuthConfig($decoder->decode($google_auth_config['client_id_json'], 'json'));
    }
    if (!empty($google_auth_config['refresh_token'])) {
      $google_client->fetchAccessTokenWithRefreshToken($google_auth_config['refresh_token']);

    }
    if (!empty($google_auth_config['redirect_uri'])) {
      $google_client->setRedirectUri($google_auth_config['redirect_uri']);
    }

    return $google_client;
var_dump$google_客户端有这个,它看起来确实有它需要的身份验证块访问_令牌和刷新_令牌。
[token:Google_Client:private]=>array6{[access_token]=>string131由Google客户端使用RefreshToken[expires_in]=>int3600[scope]=>string86生成的一个看起来像散列的大东西https://www.googleapis.com/auth/youtubepartner https://www.googleapis.com/auth/youtube [令牌类型]=>string6承载器[已创建]=>int1566992903[refresh_token]=>Google Oauth2生成的string45 token}

如果您查看该方法的文档,它会告诉您响应的含义


PS-$queryParams确实包含正确的OnBehalfOfContentTowner值。您应该阅读完整的响应,而不仅仅是状态代码,它会让您了解正在发生的事情。我添加了另一条语句来打印消息正文。没有,因此也没有帮助。此处id10t错误。用于响应的代码只是创建一个新的one、 它没有得到服务调用的结果。是的,如果成功,我应该得到204。我得到200,并想知道为什么。文档在4xx上有各种帮助,但在我的exprece 200和204中2xx.TBH上没有任何帮助。在谷歌API中,这可能只是缺少文档通知。完整的响应是什么关于美元的答复