var provider = new firebase.auth.FacebookAuthProvider();
provider.addScope('user_friends');
provider.addScope('user_likes');
// This will open the Facebook sign in page and ask user to consent
// to the additional scopes.
firebase.auth().signInWithPopup(provider).then(function(result) {
if (result.user) {
// Additional user info like Facebook account url, gender, etc.
console.log(result.additionalUserInfo.profile);
// Facebook access token returned in the process
// for the scopes requested.
console.log(result.credential.accessToken);
}
});
2条答案
按热度按时间piztneat1#
这用于添加Facebook OAuth 2.0范围,例如:'public_profile'、'email'、'user_likes'、'user_friends'等。例如:
dpiehjr42#
如果有人提出这个问题:
provider.addScope('scope')
示例scope = email
请求用户访问其电子邮件的权限。身份验证提供商“例如Google”会告诉用户,以便用户可以拒绝或授予此权限。如果授予此权限,则用户将登录,开发人员可以检索此范围。