Helper library for working with token server on react
Installation
$ yarn add @rss/auth-react
Client Usage (react)
Initialize
Client.checkIfAuthenticated should be call in the app.component
import React from "react";
const Wrapper = () => {
Client.checkIfAuthenticated("URL_TO_AUTHENTICATE_USER");
return <App />;
};
Client API
Client.checkIfAuthenticated('URL_TO_AUTHENTICATE_USER')
check if user is authenticate. if not, redirect user to authentication url
Client.getUserToken()
get user token if available
Client.redirectToAuthentication('URL_TO_AUTHENTICATE_USER')
redirect user to token server for authentication