Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

OAuth2 session manager

License

NotificationsYou must be signed in to change notification settings

Sokkuri/Kogitte

Repository files navigation

cinpm

OAuth2 session manager

This package supports/uses only the password and refresh flow!

Setup & Build

Install all dependencies:

npm install

Build:

npm run build

Usage

Initial configuration:

import{AuthConfig}from"kogitte";AuthConfig.init({// RequiredclientId:"clientId",tokenUrl:"tokenUrl",logoutUrl:"logoutUrl",// OptionallocalStorageKey:"localStorageKey",onSessionExpire:()=>{ ...}});

Session Manager

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();

[8]ページ先頭

©2009-2025 Movatter.jp