Because I was getting the notification that getProfile() will be deprecated I have changed it to getUserInfo() but when I did this and I try to login but using this will not get the user profile and it will give me the error 401 (Unauthorized).
I am using Angular 2 and followed the configuration from: https://auth0.com/docs/quickstart/spa/angular2/04-user-profile
Changed getProfile to getUserInfo.
The code now looks like this:
// Add callback for the Lock `authenticated` event
this.lock.on("authenticated", (authResult) => {
localStorage.setItem('id_token', authResult.idToken);
// Fetch profile information
this.lock.getUserInfo(authResult.idToken, (error, profile) => {
if (error) {
// Handle error
alert(error);
return;
}
localStorage.setItem('profile', JSON.stringify(profile));
this.userProfile = profile;
});

You cannot use id_token with getUserInfo method.
you need to use authResult.accessToken
I tried this but accessToken is undefined.
I experienced same issue several minutes ago and to make it worked I replaced id_token to accessToken.
this.lock.getUserInfo(authResult.accessToken, (error, profile) => {
if (error) {
// tmp error handling
alert(`Auth service 2: ${error}`);
return;
}
profile.user_metadata = profile.user_metadata || {};
this.storage.set('profile', JSON.stringify(profile));
this.user = profile;
});
Lock version: 10.7.2
I hope it will help you.
you should use the access token, there is an example in the readme https://github.com/auth0/lock#example
@tomaszczechowski Thank you, changing authResult.idToken to authResult.accessToken worked.
This should be re-opened until the website is updated with the most recent documentation.
This document uses the latest version of Lock (version 10).
Most helpful comment
I experienced same issue several minutes ago and to make it worked I replaced id_token to accessToken.
Lock version: 10.7.2
I hope it will help you.