我是新来的谷歌oauth
和openid
连接,可以说我需要服务帐户,用户在我的YouTube频道中存储视频,我创建了服务,如docs.but所示,但我不知道如何获得访问令牌可以说,我这样的代码如何从服务帐户获取访问令牌
$param = $this->getParameter('kernel.root_dir').'/xxxx.json';
$client = new \Google_Client();
$client->setClientId('xxxxxxxx');
$client->setScopes('https://www.googleapis.com/auth/youtube');
$client->setRedirectUri('http://localhost:8000/youtube/1/token');
putenv('GOOGLE_APPLICATION_CREDENTIALS='.$param.'');
$authurl = $client->createAuthUrl();
$youtube = new \Google_Service_YouTube($client);
file_get_contents($authurl);
当我运行file_get_contents($authurl)
正在逐渐401 error
,我在这里做什么错误?
感谢的人,是疗法任何生命时间刷新令牌,并且是疗法任何理由的YouTube不支持服务帐户? –
刷新令牌*应该*不会过期,但他们可以,你将不得不留意它,并通知自己,如果它。如果在六个月内未使用,它将会过期。除此之外,你应该是安全的。 – DaImTo
好的,谢谢你:-) –