简体   繁体   English

使用社交媒体登录后如何获取用户的详细信息?

[英]How to get the user's details after logging in with social media?

I am using firebase for authentication and using plain javascript (not AngularJS or any other framework such as Angular2 or ionic). 我正在使用Firebase进行身份验证并使用普通的javascript(不是AngularJS或任何其他框架,例如Angular2或ionic)。 After successful signing up with google or Facebook, I want to display the user name, use email and user image. 在通过google或Facebook成功注册后,我想显示用户名,使用电子邮件和用户图像。

firebase.auth().onAuthStateChanged(function(user) {
  if (user) {
    // User is signed in.
    var displayName = user.displayName;
    var email = user.email;
    var photoURL = user.photoURL;
} else {
    // User is not logged in, redirect to where you need to.
      console.log("Logged out");
}

The above is the snippet on the page which should show up after successful sign up. 上面是页面上的代码段,成功注册后应该会显示出来。

And I used the following to display the details, but the page showed up just what is written within the tags. 我使用以下内容来显示详细信息,但是页面仅显示了标记中编写的内容。

<p class="isLoggedIn">Logged In: {{user_displayName}} ({{user_email}})<p>

Where am I going wrong? 我要去哪里错了?

Any kind of help would be greatly appreciated. 任何形式的帮助将不胜感激。 Thanks. 谢谢。

your variables are only available inside the method you will not get them outside the function. 您的变量仅在方法内部可用,而不会在函数外部获取。 Also if you are not using the AngularJS then you are doing it wrong to put values in html like this, its angular way to bind data to view. 另外,如果您不使用AngularJS,则将这样的值放入html(将数据绑定到视图的角度方法)的做法是错误的。

See this on how to write data using plain javascript: https://stackoverflow.com/a/10507608/4428159 参见此内容,了解如何使用普通的javascript编写数据: https : //stackoverflow.com/a/10507608/4428159

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 社交媒体的弹出窗口 - Social media's in popup 当用户使用带有 firebase 的社交媒体登录时,如何只获取名字? - How to get just the first name when a user logs in using social media with firebase? Firebase:成功通过电子邮件登录后,如何使用Firebase API获取经过身份验证的用户令牌? - Firebase: How to get authenticated user's token using firebase api after successfully logging in with email? 如何使用suitescript获取netsuite当前的用户详细信息? - How to get netsuite’s current user details using suitescript? 如何使用香草JavaScript从用户的媒体文件中获取频率? - How to get frequency from user's media file with vanilla javascript? 社交媒体网站如何获得链接页面的预览? - How do social media sites get a preview of a linked page? 您如何获得大小相同的社交媒体按钮? - How do you get social media buttons all the same size? nextjs 元标记详细信息未出现在社交媒体帖子上 - nextjs meta tag details not appearing on social media post Angular4社交媒体Facebook分享页面,包含详细信息 - Angular4 Social Media Facebook share page with details 通过第三方Web应用程序的用户帐户配置文件实现安全的社交媒体访问 - Implementing a secure social media access through a third party web application's user account profile
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM