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 oneslogin: 'embedded', // If user authentication is handled in-appsupport: 'legacy', // Set globally or locally; `"legacy"` or `undefined` will use iframeserverConfig: {
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 existlogin: 'redirect', // If user authentication is handled in external Web appsupport: 'modern', // Set globally or locally; `"modern"` will use native fetch
});
Example 3:
const tokens = forgerock.TokenManager.getTokens({
query: {
code: 'lFJQYdoQG1u7nUm8 ... ', // Authorization code from redirect URLstate: 'MTY2NDkxNTQ2Nde3D ... ', // State from redirect URL
},
});
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 support: 'legacy', // Set globally or locally; `"legacy"` or `undefined` will use iframe 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 support: 'modern', // Set globally or locally; `"modern"` will use native fetch });
Example 3:
const tokens = forgerock.TokenManager.getTokens({ query: { code: 'lFJQYdoQG1u7nUm8 ... ', // Authorization code from redirect URL state: 'MTY2NDkxNTQ2Nde3D ... ', // State from redirect URL }, });