私はfirebaseを認証に使用し、プレーンなjavascript(AngularJSやAngular2やionicなどの他のフレームワークではない)を使用しています。 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");
}
上記のコードは、正常にサインアップした後に表示されるページ上のスニペットです。
詳細を表示するには以下のようにしましたが、タグ内に書かれた内容がページに表示されました。
<p class="isLoggedIn">Logged In: {{user_displayName}} ({{user_email}})<p>
どこが間違っていますか?
どんな種類のヘルプをいただければ幸いです。ありがとう。
右、 'のdocument.getElementByIdは( 'サインインステータス')のTextContent = 'に署名';。 のdocument.getElementById( 'アカウントの詳細')のTextContent = JSON.stringify({ のdisplayName:のdisplayName、 メール:メール、 にphoneNumber:にphoneNumber、 photoURL:photoURL、 UID:UID、 accessToken:accessToken 、 providerData:providerData }、null、 ''); 'これはスクリプト内で必要でした –