forcedotcom / SalesforceMobileSDK-Android

Android SDK for Salesforce
Other
341 stars 388 forks source link

How to Refresh Access Token Within SDK Without Losing Session #2636

Closed imransiddiquirn closed 4 days ago

imransiddiquirn commented 4 days ago

Hi team,

I’m looking for a way to refresh the access token directly within the Salesforce Mobile SDK for react-native-force to avoid session loss. Currently, I’m manually refreshing the token by calling the API endpoint for token refresh (/services/oauth2/token) using the stored refresh token and updating the local state with the new access token.

Issue: After refreshing the token this way, the SDK doesn’t seem to recognize the new token, resulting in a lost session and forcing the user to reauthenticate.

Request: Is there a method within the SDK to renew the access token, or a recommended approach for refreshing it internally without disrupting the session?

Thank you!

wmathurin commented 4 days ago

There is a refreshToken exposed on UserAccountManager. You should use that.