YouTube 数据 API - 从电子邮件中获取频道 ID [英] YouTube Data API - Get Channel ID from Email

查看:33
本文介绍了YouTube 数据 API - 从电子邮件中获取频道 ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Youtube 数据 API 检索 Youtube 频道 ID 和名称,但我得到的是空项目.我只有 Youtube 用户电子邮件帐户.是否只能从电子邮件中获取频道详细信息?

I'm trying to retrieve Youtube channel ID and name using Youtube data API but I'm getting empty item. I have only the Youtube user email account. Is there away to get the channel details from the email only?

https://www.googleapis.com/youtube/v3/channels?part=snippet&key={YOUR_API_KEY}

https://www.googleapis.com/youtube/v3/channels?part=snippet&key={YOUR_API_KEY}

推荐答案

无法从用户电子邮件中获取用户频道 ID.我曾尝试使用 forUsername 参数,但这仅适用于某些用户(遗留问题).我发现的唯一方法是使用 Google Signin for iOS 实现,它允许您使用您的 google 帐户登录.为了能够获得 YouTube 数据,它需要额外的范围配置,如下所示:

There is no way to get the user channel ID from user email. I have tried to use forUsername parameter but this works only for some users (legacy issue). The only I have found is to use Google Signin for iOS implementation which allow you yo signin with your google account. In order to have that ability to get YouTube data it require additional scope configuration as follows:

let scope: NSString = "https://www.googleapis.com/auth/youtube.readonly"
let currentScopes: NSArray = GIDSignIn.sharedInstance().scopes
GIDSignIn.sharedInstance().scopes = currentScopes.arrayByAddingObject(scope)

现在,您可以使用访问令牌运行以下 YouTube 数据 API:

Now, you can run the following YouTube data API with Access Token:

https://www.googleapis.com/youtube/v3/channels?part=id&mine=true&access_token={oauth_token}

访问令牌,您将从 user.authentication.accessToken

这篇关于YouTube 数据 API - 从电子邮件中获取频道 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆