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

Add a reauthenticate method to expose refresh token use

Open tqc opened this issue 7 years ago • 3 comments

This update improves the handling of refresh tokens when using a javascript api rather than the native makeRequest. Somewhat related to #82.

JS code can call reauthenticate to get a new token when a request fails due to an expired token.

I also added saving of the new token after a refresh - previously the new token would be in memory for subsequent makeRequest calls, but the next app startup would return the expired token.

iOS only for now - the android implementation is fairly straightforward, but isn't included as I'm not set up to test that at the moment.

tqc avatar Oct 09 '17 00:10 tqc

@tqc, what about expires_in? How to refresh token without this field?

monolithed avatar Dec 23 '17 12:12 monolithed

@monolithed An expiry time isn’t needed - if the token you have doesn’t work, try getting a new one. You could check the expiry beforehand if you really wanted to, but it wouldn’t be particularly reliable anyway - there are plenty of other reasons for a token to expire.

tqc avatar Dec 23 '17 21:12 tqc

Something like this would be really helpful for me, since I'm having a hard time getting makeRequest to work, but JS fetch would be easy to get setup

sb8244 avatar Feb 07 '19 02:02 sb8244