This library permits to set OAuth2 API config at app entry point (signin) and apply an user transparent worfklow to manage user tokens/credentials on Webservice/API calls.
- Signin (optional : but Transparent user workflow not firing): save credentials then set OAuth2 workflow -> all POST / GET / PUT / DELETE request will pass Bearer with access_token on calling url (if exists, if not -> fire transparent user workflow)
- Transparent user workflow (optional : a Webservice/API call can be done without access_token so Transparent user workflow not firing) : if Webservice/API authentication method fails with 401, automatically calls GET access_token url by refresh_token (if exists)
-
- If fails : automatically call GET access_token url by credentials (if exists)
-
-
- If fails : call callback methods (by example : display message + redirect Signin screen)
-
-
-
- If success : fire orignal request
-
-
- If success : fire orignal request
$ yarn add 'react_native_service_provider_oauth2'ServiceProvider.setOAuth2Data(GET_ACCESS_TOKEN_URL, CLIENT_ID, CLIENT_SECRET)
Set OAuth2 logout callback (optional -> if Webservice/API call fails : return Reject Promise if is not configured): method called if all transparent workflow fails
ServiceProvider.setOAuth2LogoutCallback(CALLBACK_METHOD)
Set OAuth2 save tokens method (optional -> if Webservice/API call fails : return Reject Promise if is not configured): method to save tokens on local device (persistant data) when GET_ACCESS_TOKEN_URL() call returns success
ServiceProvider.setSaveTokensMethod(SAVE_LOCAL_TOKENS_METHOD)
