Class TokenManagerAbstract

Constructors

Methods

  • Token Manager class that provides high-level abstraction for Authorization Code flow, PKCE value generation, token exchange and token storage.

    Supports both embedded authentication as well as external authentication via redirects

    Example 1:

    const tokens = forgerock.TokenManager.getTokens({
    forceRenew: true, // If you want to get new tokens, despite existing ones
    login: 'embedded', // If user authentication is handled in-app
    serverConfig: {
    timeout: 5000, // If using "legacy", use a short timeout to catch error
    },
    });

    Example 2:

    const tokens = forgerock.TokenManager.getTokens({
    forceRenew: false, // Will immediately return stored tokens, if they exist
    login: 'redirect', // If user authentication is handled in external Web app
    });

    Example 3:

    const tokens = forgerock.TokenManager.getTokens({
    query: {
    code: 'lFJQYdoQG1u7nUm8 ... ', // Authorization code from redirect URL
    state: 'MTY2NDkxNTQ2Nde3D ... ', // State from redirect URL
    },
    });

    Parameters

    Returns Promise<void | OAuth2Tokens>