通过访问令牌访问YouTube频道标题需要什么范围?
问题描述:
我正在研究一个使用Google的PHP API库的项目。我目前使用的范围与offline
访问:通过访问令牌访问YouTube频道标题需要什么范围?
https://www.googleapis.com/auth/youtube.force-ssl
https://www.googleapis.com/auth/youtube.upload
但是,这并没有给我访问得到证实的通道的通道标题。
然后我尝试添加多个范围:
https://www.googleapis.com/auth/youtube.readonly
https://www.googleapis.com/auth/youtubepartner
https://www.googleapis.com/auth/youtubepartner-channel-audit
但我也有同样的结果。是否有一个范围,这与我缺少的YouTube无关?
-
这里是我使用的代码,请注意$this->client
是Google_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
和snippet
下的现场参数'title
'。
这里是我使用API explorer:
"title": "Steve Jobs" //that's my title
我认为_force SSL_范围是一样的_just_ YouTube的范围。我会考虑这个 – dmb
包括两个范围 – noogui