

OAuth2 session manager
This package supports/uses only the password and refresh flow!
Install all dependencies:
Build:
import{AuthConfig}from"kogitte";AuthConfig.init({// RequiredclientId:"clientId",tokenUrl:"tokenUrl",logoutUrl:"logoutUrl",// OptionallocalStorageKey:"localStorageKey",onSessionExpire:()=>{ ...}});
Login:
Requests the access and the refresh token from the configured token URL and saves this data in the local storage.
import{UserSessionManager}from"kogitte";newUserSessionManager().login("username","password","optional captcha response");
Optionally a captcha response can be provided. This data is sent with the login in thecaptcha
parameter.
Logout:
Sends an authorized POST request to the configured URL and removes afterwards the session in the local storage.
import{UserSessionManager}from"kogitte";newUserSessionManager().logout("optional data");
Optionally data can be provided. This data is sent in the request body.
Get current session:
Gets the data from the local storage and checks if the access token is still valid. Is this not the case, a refresh attempt is made.If this fails the saved session gets removed. Is the token still valid or the refreshment succeeded, the current session gets returned.
import{UserSessionManager}from"kogitte";newUserSessionManager().getCurrentSession();
Session exists:
Checks if a session is stored in the local storage.
import{UserSessionManager}from"kogitte";newUserSessionManager().sessionExists();