使用 Youtube API 获取用户电子邮件 [英] Get user email using Youtube API
问题描述
如何使用 Youtube API 获取经过身份验证的用户电子邮件?
How can I get authenticated user email using Youtube API?
我尝试使用 channels.list
:
I tried using channels.list
:
GET https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&mine=true&key={YOUR_API_KEY}
它不会返回电子邮件...
It doesn't return the email...
我使用这个 NodeJS 模块与 Youtube API 通信:
I communicate with Youtube API using this NodeJS module:
var Youtube = require("youtube-api");
Youtube.authenticate({
type: "oauth",
token: ACCESS_TOKEN
});
Youtube.channels.list({
"part": "brandingSettings",
"mine": true
}, function (err, data) {
console.log(err, data);
});
推荐答案
要获取用户的电子邮件地址,您需要在 OAuth 期间首先获得他们的许可.Google 的 OAuth 对此有专门的范围.我不熟悉 Node.js youtube-api
模块,但您必须让它包含一个额外的 OAuth 范围:https://www.googleapis.com/auth/userinfo.email
.然后电子邮件地址将在对 http://googleapis.com/oauth2/v1 的请求的响应中可用/userinfo.
To get a user's email address, you'll need to get their permission first during OAuth. Google's OAuth has a scope specifically for this. I'm not familiar with the Node.js youtube-api
module, but you'll have to get it to include an additional OAuth scope: https://www.googleapis.com/auth/userinfo.email
. Then the email address will be available in the response from a request to http://googleapis.com/oauth2/v1/userinfo.
这篇文章可能会有所帮助:http://javascriptplayground.com/blog/2013/06/node-and-google-oauth/
This post may be helpful: http://javascriptplayground.com/blog/2013/06/node-and-google-oauth/
这篇关于使用 Youtube API 获取用户电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!