使用 Angular2 在 Firebase 中获取用户身份验证配置文件信息

编程入门 行业动态 更新时间:2024-10-22 22:52:33
本文介绍了使用 Angular2 在 Firebase 中获取用户身份验证配置文件信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

你能帮我吗?我无法在 Angularfire 身份验证中获取用户的个人资料信息,例如他们的 Facebook 个人资料图片或 Facebook 名称.请帮忙.非常感谢!

Can you help me? I can't get the user's profile information in Angularfire Authentication like their facebook's profile picture or facebook name. Please help. Thanks a lot!

我已经尝试过这段代码,但它不起作用.我使用 Angular 2 TypeScript.

I've tried this code but its not working. I use Angular 2 TypeScript.

var user = firebase.auth().currentUser;
var name, email, photoUrl, uid;

if (user != null) {
  name = user.displayName;
  email = user.email;
  photoUrl = user.photoURL;
  uid = user.uid;  // The user's ID, unique to the Firebase project. Do NOT use
                   // this value to authenticate with your backend server, if
                   // you have one. Use User.getToken() instead.
}

推荐答案

当您使用 Angularfire2 时,应该是这样:

When you are using Angularfire2 this should be the way:

constructor(public af: AngularFire) {
    this.af.auth.subscribe(auth => {
     //Here you get the user information
     console.log(auth));
    }
  }
  login() {
    this.af.auth.login({
      provider: AuthProviders.Facebook,
      method: AuthMethods.Popup,
    });
  }

查看此处了解更多信息:https://angularfire2/api/

Take a look here for more information: https://angularfire2/api/

这篇关于使用 Angular2 在 Firebase 中获取用户身份验证配置文件信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-22 11:12:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1023551.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:配置文件   身份验证   用户   信息   Firebase

发布评论

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

>www.elefans.com

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