ios - YouTube 数据 API 错误 403 权限不足
问题描述
我正在使用需要访问用户的 YouTube 订阅的 Swift 开发 IOS 应用程序。在 Google Cloud Platform 上添加我需要的所有范围并在 Firebase 中实现 GoogleSignIn 之后。我登录(GIDSignInButton),然后在发出此请求后收到如下所示的错误:
https://www.googleapis.com/youtube/v3/subscriptions?part=snippet%2CcontentDetails&mine=true&key=\(apiKey)&access_token=\(Access_Token)
.
Access_Token 是我打电话后得到的:
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?){
user.authentication.accessToken
....}
我得到的错误:
["error": {
code = 403;
errors = (
{
domain = global;
message = "Insufficient Permission";
reason = insufficientPermissions;
}
);
message = "Request had insufficient authentication scopes.";
status = "PERMISSION_DENIED";
}]
在 App Delegate 中,我设置了这个:
GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID
解决方案
我遇到了同样的问题,如果我没记错的话,它发生在我的 OAuth 同意验证状态未经验证时。我所做的工作是,除了在 Google 仪表板中提供范围之外,我还在登录前以编程方式添加了它们。
GIDSignIn.sharedInstance().scopes.append("https://www.googleapis.com/auth/youtube.upload")
GIDSignIn.sharedInstance().signIn()
推荐阅读
- python - AttributeError:“str”对象没有属性“year”
- javascript - 使用 Ajax Codeigniter 确认消息不起作用
- ios - 检测键盘何时完全可见并防止键盘外观处理代码为隐藏元素添加额外的偏移量
- python - pygettext 不会将字符串读入 .pot 文件
- arrays - 如何使用 jsonplaceholder 动态添加多个帖子
- node.js - Azure 静态 Web 应用环境变量
- django - 在没有数据持久性的情况下,如何最好地在 Django 中压缩表单:最 Djangonic 的方法是什么?
- vue.js - Vuex 操作和组合 API 的意外未捕获异常
- go - 从地图生成组合字符串
- python - 使用 pygame 在 python 中制作游戏 Checkers 但遇到轻微的逻辑错误