javascript - AngularFire Google OAuth 未检索用户的电子邮件

标签 javascript angularjs firebase angularfire

我想使用 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/

相关文章:

api - 在 Firebase 的 POST 请求中丢弃空数组

javascript - 对此代码进行改进,以比较格式中的 2 次 (HH :MM:SS)

javascript - Svelte 3,异步 onMount 还是有效的替代方案?

javascript - 未找到 Angular JS 对象

javascript - 我正在尝试将图像上传到 firebase 但代码似乎不起作用

swift - 如何在一笔事务中使用 Swift 删除 Firebase 中的多个路径

javascript - 如何使用 react 路由器渲染的问题

javascript - 用鼠标悬停关闭一个框

javascript - 你怎么 "bypass"mouse up?

javascript - 在 Ionic 应用程序的 AngularJS 中显示数据时出错