Hi there,
I am building a SPA app in Vue.js and Azure AD as the IDP.
Following this good post, I have enriched the user profile with additional data from Azure AD (like manager, direct reports…). I can see that it works from the dashboard, I can see the data.
Now, I’d like to get access to those attributes from my client using auth0-spa-js.
When I print the user’s attributes using JSON.stringify($auth.user, null, 2) }
, I can only see a few:
"given_name": "Romain",
"family_name": "Jourdan",
"nickname": "rjourdan",
"name": "Romain Jourdan",
"picture": "https://s.gravatar.com/avatar/dc9345a6f89b81f54ed990bdee43f275?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Frj.png",
"updated_at": "2020-02-02T05:33:55.159Z",
"email": "my email",
"email_verified": true,
"sub": "waad|3yeuY3hwypBFOu6KZ2d6WHLVDZq40jgJsdtlytm2dck"
What about the other ones? I need to check the last_login and app_metadata.
Based on the Auth0Client Class and Read-Metadata with Lock, I thought I would succeed.
if(this.$auth.isAuthenticated) {
this.$auth.getTokenSilently()
.then((token) => {
this.$auth.lock.getUserInfo(token, function(error, profile) {
if (!error) {
console.log("otherMail "+profile.app_metadata.otherMail);
}
});
}).catch((error) => {
console.log("problem: "+error);
});
No joy, I am successfuly getting a token but $auth.lock is ‘undefined’.
I understand that I can also use the Management API to get to the additional profiles. Is this recommended to use it from the SPA or should we use it only in the backend?
May be I am not on the right track. Any clue?