Private
clientPrivate
cryptoPrivate
pendingPrivate
storageComplete the Fief authentication process by exchanging the authorization code available in query parameters and store the tokens and user information in the browser session.
Under the hood, it automatically handles the PKCE code challenge.
The exact same redirectURI
you passed to the authorization URL.
Return the token information object available in session, or null
if no current session.
The token information, or null if not available.
const tokenInfo = fiefAuth.getTokenInfo();
Return the user information object available in session, or null
if no current session.
The user information, or null if not available.
const userinfo = fiefAuth.getUserinfo();
Clear the access token and the user information from the browser storage and redirect to the Fief logout endpoint.
A valid URL where the user will be redirected after the logout process.
fiefAuth.logout('http://localhost:8080')
Start a Fief authorization process and perform the redirection.
Under the hood, it automatically handles the PKCE code challenge.
Your callback URI where the user will be redirected after Fief authentication.
Optional
parameters: { Optional
extrasOptional object containing specific parameters.
Optional
lang?: stringOptional parameter to set the user locale.
Should be a valid RFC 3066 language identifier, like fr
or pt-PT
.
Optional
scope?: string[]Optional list of scopes to ask for. Defaults to ['openid']
.
Optional
state?: stringOptional string that will be returned back in the callback parameters to allow you to retrieve state information.
fiefAuth.redirectToLogin('http://localhost:8080/callback.html');
Set the user locale.
fiefAuth.redirectToLogin('http://localhost:8080/callback.html', { lang: 'fr-FR' });
Refresh user information from the Fief API using the access token available in session.
The fresh user information is returned and automatically updated in the session storage.
The refreshed user information
fiefAuth.refreshUserinfo()
.then((userinfo) => {
console.log(userinfo);
})
.catch((err) => {
if (err instance of fief.browser.FiefAuthNotAuthenticatedError) {
console.error('User is not logged in');
}
})
;
Helper class to integrate Fief authentication in a browser application.
Example