react-native-oauth
react-native-oauth copied to clipboard
Add a reauthenticate method to expose refresh token use
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, what about expires_in
? How to refresh token without this field?
@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.
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