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?
CodePudding user response:
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.
CodePudding user response:
The signInWithCustomToken()
method returns a Promise which resolves with a UserCredential
and not a User
.
So you need to do as follows:
async function signinWithToken(data, sendResponse) {
const { token } = data;
console.log(token);
signInWithCustomToken(auth, token)
.then((userCredential) => {
console.log(userCredential.user);
//..
})