YouTube 数据 API 错误 403 权限不足 [英] YouTube Data API Error 403 Insufficient Permission
问题描述
我正在使用 Swift 开发一个 IOS 应用,该应用需要访问用户的 YouTube 订阅.在 Google Cloud Platform 上添加我需要的所有范围并在 Firebase 中实施 GoogleSignIn 之后.我登录 (GIDSignInButton),然后在发出此请求后收到如下所示的错误:
I'm working on an IOS app using Swift that requires accessing to the user's YouTube subscriptions. After adding all scopes I need on Google Cloud Platform and implementing GoogleSignIn in Firebase. I sign in (GIDSignInButton), then I get the error shown down below after making this request:
https://www.googleapis.com/youtube/v3/subscriptions?part=snippet%2CcontentDetails&mine=true&key=(apiKey)&access_token=(Access_Token)
.
Access_Token 是我打电话后得到的:
The Access_Token is the one I got after I call:
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 中我设置了这个:
In App Delegate I set this:
GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID
推荐答案
我遇到了同样的问题,如果我没记错的话,它发生在我的 OAuth 同意验证状态未验证时.为了让它发挥作用,除了在 Google 仪表板中提供范围之外,我还在登录前以编程方式添加了它们.
I had the same problem and, if I remember correctly, it occurred when my OAuth consent verification status was unverified. What I did to make it work was, in addition to supplying scopes in the Google dashboard, I added them programmatically before signing in.
GIDSignIn.sharedInstance().scopes.append("https://www.googleapis.com/auth/youtube.upload")
GIDSignIn.sharedInstance().signIn()
这篇关于YouTube 数据 API 错误 403 权限不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!