I am using signInWithCustomToken()
after initiating it on the server.
async function signinWithToken(data, sendResponse) {
const { token } = data;
console.log(token);
signInWithCustomToken(auth, token)
.then((user) => {
console.log(user);
sendResponse({ success: true, user });
})
.catch((err) => {
sendResponse({ success: false, message: err.message
});
});
}
The problem is that the user object returned doesn’t include the user details like displayName, email, etc…
Is there something I could do about it?
2
Answers
The
signInWithCustomToken()
method returns a Promise which resolves with aUserCredential
and not aUser
.So you need to do as follows:
A custom token only contains the properties/claims that you put into it. Firebase doesn’t add any information to the custom token, so if you find certain values missing, it’s because your code didn’t add them while minting the token.
Also see the Firebase documentation on minting a custom token using the Admin SDK.