我想使用 AngularFire 从 Google OAuth 获取电子邮件地址,但在弹出窗口中,它并不请求电子邮件权限。
这是来自 Firebase Google auth doc 的代码
var ref = new Firebase("https://<your-firebase>.firebaseio.com");
ref.authWithOAuthPopup("google", function(error, authData) { /* Your Code */ }, {
scope: "email"
});
它适用于我的 Angular 应用程序,但我如何修复我的 Angular 代码以执行相同的操作?
var ref = new Firebase("https://<your-firebase>.firebaseio.com");
var auth = $firebaseAuth(ref);
auth.$authWithOAuthPopup("google").then(function(authData) {
/* Code */
}).catch(function(error) {
console.error("Authentication failed:", error);
});
Link to the same problem with answer ,但我没有得到答案以及如何解决它。
最佳答案
您尝试过传递选项吗?
var ref = new Firebase("https://<your-firebase>.firebaseio.com");
var auth = $firebaseAuth(ref);
auth.$authWithOAuthPopup("google", { scope: 'email' }).then(function(authData) {
/* Code */
}).catch(function(error) {
console.error("Authentication failed:", error);
});
正如 Kato 所指出的,文档也提供了该信息:link
关于javascript - AngularFire Google OAuth 未检索用户的电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30520067/