具有 Google 电子邮件范围的 Firebase Angular OAuth,auth.$authWithOAuthPopup 与 ref.authWithOAuthPopup

编程入门 行业动态 更新时间:2024-10-27 00:34:25
本文介绍了具有 Google 电子邮件范围的 Firebase Angular OAuth,auth.$authWithOAuthPopup 与 ref.authWithOAuthPopup的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我成功地使用 Firebase 的 angular 库对 Facebook 和 Google 的用户进行身份验证,但是在使用 firebaseAuth 的 $authWithOAuthPopup 时,我在检索用户的电子邮件时遇到了麻烦.

I'm successfully using Firebase's angular library to auth users against Facebook and Google, but I'm having troubling retrieving the user's email when using firebaseAuth's $authWithOAuthPopup.

这是我的登录功能.

var ref = new Firebase(FIREBASE_URL);
var auth = $firebaseAuth(ref);      
loginGoogle: function () {
    console.log('Logging in Google.');
    return auth.$authWithOAuthPopup('google', function(error, user){
      //TODO: Handle Failed login better
      console.log('Google login failed');
      console.log(error);
    },{
      scope: 'email'
    });
  };

这会弹出google auth窗口并登录成功.但是,在访问权限窗口中,它不会请求电子邮件"范围访问.

This will pop up the google auth window and log in successfully. But, in the access permissions window, it doesn't request the 'email' scope access.

如果我使用 ref.authWinOAuthPopup(...) 而不是 auth.$authWithOAithPopup(...) 它确实会正确请求电子邮件权限,并在身份验证后提供该信息.

If I use ref.authWinOAuthPopup(...) instead of auth.$authWithOAithPopup(...) it does properly request the email perms, and delivers that info after auth.

我在这里做错了吗?或者,这是我应该报告的 Angularfire 错误吗?

Am I doing something wrong here? Or, is it an Angularfire bug that I should be reporting?

Angularfire v0.9.2.

Angularfire v0.9.2.

推荐答案

这就是我所做的并且对我有用

This is what I did and it worked for me

.config(function ($firebaseRefProvider) {$firebaseRefProvider.registerUrl('https://****.firebaseio/');})

然后在控制器中

loginWithGoogle: function(){
    var ref = $firebaseRef.default;
    ref.authWithOAuthPopup("google", function(error, authData) {

      if (error) {
        ...
      } else {
        console.log(authData.google.email);

      }
    },{scope: 'email'});
  }

这篇关于具有 Google 电子邮件范围的 Firebase Angular OAuth,auth.$authWithOAuthPopup 与 ref.authWithOAuthPopup的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-22 11:01:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1023504.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:电子邮件   Angular   Firebase   Google   authWithOAuthPopup

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!