gpt4 book ai didi

youtube - 通过访问 token 访问YouTube channel 标题需要什么范围?

转载 作者:行者123 更新时间:2023-12-03 05:35:59 25 4
gpt4 key购买 nike

我正在开发一个使用Google PHP API库的项目。我目前正在使用具有offline访问权限的范围:

  • https://www.googleapis.com/auth/youtube.force-ssl
  • https://www.googleapis.com/auth/youtube.upload

  • 但这并不能让我访问获得经过身份验证的 channel 的 channel 标题。

    然后,我尝试添加更多范围:
  • https://www.googleapis.com/auth/youtube.readonly
  • https://www.googleapis.com/auth/youtubepartner
  • https://www.googleapis.com/auth/youtubepartner-channel-audit

  • 但是我也有同样的结果。有没有我所缺少的与YouTube不相关的范围?

    --

    这是我正在使用的代码,请注意 $this->clientGoogle_Client的实例:
    /**
    * Fetch channel title
    *
    * @return string
    */
    public function fetchChannelTitle() {

    /** @var \Google_Service_YouTube_Channel $details */
    $details = $this->getChannelDetails();
    $snippet = $details->getSnippet();

    return $snippet->getTitle();
    }

    /**
    * Get channel details
    *
    * @throws YouTubeException
    */
    public function getChannelDetails()
    {
    if (!$this->access_token) {
    throw new YouTubeException('NO_REFRESH_TOKEN');
    }

    $this->client->setAccessToken($this->access_token);

    $parts = 'snippet,contentDetails,statistics';
    $params = ['mine' => true];

    $response = (new Google_Service_YouTube($this->client))->channels->listChannels(
    $parts,
    $params
    );

    return $response->getItems()[0];
    }

    最佳答案

    别忘了包含这个scope

    https://www.googleapis.com/auth/youtube

    以及 title下的字段参数' snippet'。

    这是我的 API explorer:
    "title": "Steve Jobs" //that's my title

    关于youtube - 通过访问 token 访问YouTube channel 标题需要什么范围?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44173934/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com