dongsu3654 2017-03-29 09:00
浏览 41

PHP Google_Client插入youtube playlistItem(2-leg-oauth)

My web using the PHP Google_Client to insert the youtube playlistItem in my playlist (2-leg-oauth), and get the error Client is unauthorized to retrieve access tokens using this method. Where can I setting the server using my-account@gmail.com to have the same permission to access google api such like insert playlistItem, or is there having another way without using my-account@gmail.com to get same permission?

PHP Code:

putenv('GOOGLE_APPLICATION_CREDENTIALS=client_secret.json');
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope('https://www.googleapis.com/auth/youtube');
$client->setSubject('my-account@gmail.com');
  • 写回答

2条回答 默认 最新

  • double2022 2017-03-29 12:42
    关注

    If you have delegated domain-wide access to the service account and you want to impersonate a user account, specify the email address of the user account use

    $client->setSubject($user_to_impersonate);
    

    The YouTube API doesn't support delegated domain-wide access or service accounts. You will need to authenticate with Oauth2.

    see PHP Code Samples

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分