1.0.7 • Published 12 months ago

oauth2-module-ts v1.0.7

Weekly downloads
-
License
ISC
Repository
-
Last release
12 months ago

OAuth2 Module

OAuth2 Module is a TypeScript module designed to manage authentication processes using the OAuth protocol and handle access tokens. The module provides a convenient interface for initiating authorization, exchanging authorization code for access tokens, logging out, and checking the token expiration.

Usage

  1. Initialize the Module:

    import { OAuthModule, OAuthModuleConfig } from "oauth2-module";
    
    // OAuthModule Configuration
    const oauthConfig: OAuthModuleConfig = {
      clientId: "Your Client ID",
      redirectUri: "Redirect URI",
      authorizationUrl: "Authorization URL",
      logoutUrl: "Logout URL",
      tokenUrl: "Token Exchange URL",
      scope: ["required scopes"],
      postLogoutRedirectUri: "Post-Logout Redirect URI",
    };
    
    const oauthInstance = OAuthModule.getInstance(oauthConfig);
  2. Get Authorization URL:

    try {
      await oauthInstance.getAuthorizationUrl();
    } catch (error) {
      console.error(error);
    }
  3. Exchange Authorization Code for Token:

    try {
    await oauthInstance.exchangeCodeForToken();
    } catch (error) {
    console.error(error);
    }
  4. Logout:

    try {
    await oauthInstance.logout();
    } catch (error) {
    console.error(error);
    }
1.0.7

12 months ago

1.0.6

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago