使用YouTube API获取用户的电子邮件 [英] Get user email using Youtube API
问题描述
我怎样才能使用YouTube API认证的用户的电子邮件?
我尝试使用 channels.list
:
GET https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&mine=true&key={YOUR_API_KEY}$c$c>
不退还的电子邮件...
我使用这个模块的NodeJS 与YouTube API通信:
VAR的Youtube =要求(统称YouTube-API);Youtube.authenticate({
类型:OAuth的
令牌:ACCESS_TOKEN
});Youtube.channels.list({
一部分:brandingSettings
我的:真
},功能(呃,数据){
的console.log(ERR,数据);
});
要获取用户的电子邮件地址,你需要的OAuth期间先得到他们的许可。谷歌的OAuth有一个范围,专门为这一点。我不熟悉Node.js的的YouTube-API
模块,但你必须得到它包括一个附加的OAuth范围: HTTPS ://www.googleapis.com/auth/userinfo.email
。随后的电子邮件地址将在从请求的响应提供给 http://googleapis.com/oauth2/v1 /用户信息。
这帖子可能会有所帮助: http://javascriptplayground.com /博客/ 2013/06 /节点和谷歌 - 的OAuth /
How can I get authenticated user email using Youtube API?
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...
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);
});
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.
This post may be helpful: http://javascriptplayground.com/blog/2013/06/node-and-google-oauth/
这篇关于使用YouTube API获取用户的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!