【发布时间】:2017-10-07 09:06:12
【问题描述】:
我是 google oauth 和 openid 连接的新手,可以说我需要用户在我的 youtube 频道中存储视频的服务帐户,我创建了文档中给出的服务。但我不知道如何获取访问令牌让像这样说出我的代码
$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,我在这里犯了什么错误?
【问题讨论】:
标签: php oauth oauth-2.0 google-oauth youtube-data-api