react-native-auth0 icon indicating copy to clipboard operation
react-native-auth0 copied to clipboard

Auth0. getTokenSilently() functionality (update cached user profile silently)

Open XelNizar opened this issue 1 year ago • 1 comments

Checklist

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

  1. logged in user
  2. update user info in custom DB
  3. forceRefresh credentials
  4. 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

XelNizar avatar Sep 24 '24 11:09 XelNizar

Hi, I'm also experiencing the same issue. Would really appreciate any updates on this.

MarkintoshZ avatar Oct 14 '24 21:10 MarkintoshZ

@MarkintoshZ I have found a workaround for this:

  1. created an action in auth0 where i check if its a refresh token event using this check: if (event.transaction?.protocol === "oauth2-refresh-token")
  2. if so i requested an M2M token where i can call my backend service to receive the user info!
  3. 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);
  4. 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 avatar Dec 12 '24 10:12 XelNizar

@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?

poovamraj avatar Jan 18 '25 17:01 poovamraj

Closing this for now. Feel free to comment here to reopen this issue.

poovamraj avatar Feb 05 '25 11:02 poovamraj