react-native-auth0
react-native-auth0 copied to clipboard
Auth0. getTokenSilently() functionality (update cached user profile silently)
Checklist
- [X] The issue can be reproduced in the react-native-auth0 sample app (or N/A).
- [X] I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- [X] I have looked into the API documentation and have not found a suitable solution or answer.
- [X] I have searched the issues and have not found a suitable solution or answer.
- [X] I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- [X] I agree to the terms within the Auth0 Code of Conduct.
Description
Is there is any way to do the same thing that getTokenSilently does? in my case i want to update the userProfile cache in auth0 after any change to my custom database, but that FetchUserScript happens only after an actual authorization process. so in my case i want to be able to hit the authorize endpoint silently without letting the user do any interaction. Doing a forceRefresh didnt fix the problem
Reproduction
- logged in user
- update user info in custom DB
- forceRefresh credentials
- will still have old user data unless you logout + log in back again
Additional context
No response
react-native-auth0 version
3.2.1
React Native version
0.74.5
Expo version
No response
Platform
iOS
Platform version(s)
17
Hi, I'm also experiencing the same issue. Would really appreciate any updates on this.
@MarkintoshZ I have found a workaround for this:
- created an action in auth0 where i check if its a refresh token event using this check:
if (event.transaction?.protocol === "oauth2-refresh-token") - if so i requested an M2M token where i can call my backend service to receive the user info!
- update the app/user metadata (depends on the data you want to update) inside the action itself:
api.user.setAppMetadata("custom_data",updatedUserData.custom_data); - call the getCredentials method with the 4th parameter as true (for forceRefresh the token):
this.auth0.credentialsManager.getCredentials(undefined, undefined, undefined, true);
this worked for me, i hope this will be helpful for you :)
@XelNizar @MarkintoshZ The set user happens with the information obtained from the ID token. So if the information you have set is not found in the ID token the user field would not be updated.
Can you confirm if the field is set (and returned) as part of the ID token before calling getCredentials?
Closing this for now. Feel free to comment here to reopen this issue.