I am using THIS Firebase documentation to create an SSO and it is working great, like expected but there is one problem for me, the sign up returns the UPN (User Principal Name) instead of SMTP address because the UPN is different from SMTP address. Is there a way to return the SMTP address when signing up instead of the UPN? This change from UPN to SMTP is very important for this project as I need that email to run another API which requires the SMTP address. Is there any way to get the SMTP address?
I solved it, Just use the Microsoft's Graph API and pass the access token given to you when you sign in or sign up a user using Microsoft
async authenticate() {
signInWithPopup(auth, provider)
.then(async (result) => {
const credential = OAuthProvider.credentialFromResult(result);
const accessToken = credential.accessToken;
var myHeaders = new Headers();
myHeaders.append("Authorization", `Bearer ${accessToken}`);
var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' };
let response = (await (await fetch("https://graph.microsoft.com/v1.0/me", requestOptions)).json()).mail;
console.log(response);
})
.catch((error) => {
console.error(error);
});
}
this snippet will give you the actual email address rather than the UPN.