Hi All. I’m using auth0.js in a single page application. I’m able to allow the user to update their own user_metadata via the Management API, and I can verify that the user_metadata is updated by manually logging into auth0.com and looking at the user’s profile.
The issue I am having is showing the user their changes (my app has a ‘profile’ section where the user can view various things, including what is in their user_metadata).
After I call patchUserMetadata()
and it returns successfully, I call auth0.client.userInfo()
and what I thought would happen, is that the call to userInfo after patchUserMetadata wouldd return a result that contains new, updated user_metadata, but it does not. Why?
What I think is happening is this:
When the user first authenticates, I have my 'WebAuth` setup like…
auth0 = new auth0.WebAuth({
clientID: MY_CLIENT_ID,
domain: MY_DOMAIN,
responseType: 'token id_token',
audience: MY_AUDIENCE,
redirectUri: MY_REDIRECT_URI,
scope: MY_SCOPES,
leeway: 30
});
However, when the user goes to update their metadata, I do this…
this.auth0.checkSession(
{
audience: `https://MY_DOMAIN/api/v2/`,
scope: 'read:current_user update:current_user_metadata',
redirectUri: MY_REDIRECT_URI
}, (err, result) => {
var auth0Manage = new auth0.Management({
domain: MY_DOMAIN,
token: result.accessToken
});
//Call to auth0Manage.patchUserMetadata()
//Call to this.auth0.userInfo if patch was successful
});
Is the issue because I did a checkSession()
and changed the audience
?
Do I have to call checkSession()
a second time - after patchUserMetadata()
- with the original parameters???
I tried calling checkSession()
a second time, with the original parameters, then calling userInfo, and it works. However that doesn’t seem like that’s the correct thing to do/seems a little hacky to me. I feel like there’s probably something I’m missing.
Any help would be excellent!