【问题标题】:Access Youtube channels from oauth'd user从 oauth'd 用户访问 Youtube 频道
【发布时间】:2018-08-28 17:47:38
【问题描述】:

我正在尝试为使用 Google 登录我的网站的用户获取所有频道并最终获取所有视频。我正在使用 Laravel Socialite 来设置我认为应该给予适当权限的范围。然后我将访问令牌设置为会话。

public function loginGoogle()
{
   return Socialite::driver('google')->setScopes(['https://www.googleapis.com/auth/youtube.readonly',])->redirect();
}

在验证用户并保存访问令牌后处理回调时,我运行以下命令:

dd(\Youtube::getService()->channels->listChannels('snippet', ['managedByMe' => true, 'onBehalfOfContentOwner' => session('access_token')]));

\Youtube 只是我在我的网站中处理 Youtube 功能的外观。

运行代码时抛出以下错误:

Client error: `GET https://www.googleapis.com/plus/v1/people/me?prettyPrint=false` resulted in a `403 Forbidden` response:

{"error":{"errors":[{"domain":"global","re​​ason":"insufficientPermissions","message":"Insufficient Permission"}],"code":4 (截断。 ..)

我不知道是我使用了不正确的范围还是只是搞砸了更大的东西。 Youtube 的文档在这方面并没有太大帮助。他们只是说用户必须获得授权……他们是谁?

在这方面已经有几天了,但不知道下一步该去哪里。

【问题讨论】:

    标签: php laravel-5 oauth youtube-data-api laravel-socialite


    【解决方案1】:

    变化

        return Socialite::driver('google')->setScopes(['https://www.googleapis.com/auth/youtube.readonly',])->redirect();
    

        return Socialite::driver('google')->scopes(['https://www.googleapis.com/auth/youtube.readonly',])->redirect();
    

    似乎解决了它。看看documentation,为什么这不起作用是有道理的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-22
      • 2014-10-12
      • 1970-01-01
      • 1970-01-01
      • 2019-01-11
      • 2015-09-20
      • 2013-05-31
      相关资源
      最近更新 更多