Skip to content

AuthClient

Defined in: auth-client.ts:162

Manages authentication and identity for Internet Computer web apps.

const authClient = new AuthClient();
if (authClient.isAuthenticated()) {
const identity = await authClient.getIdentity();
}
await authClient.login({
onSuccess: () => console.log('Logged in!'),
});

new AuthClient(options?): AuthClient

Defined in: auth-client.ts:171

AuthClientCreateOptions = {}

AuthClient

idleManager: IdleManager | undefined

Defined in: auth-client.ts:169

getIdentity(): Promise<Identity>

Defined in: auth-client.ts:202

Returns the current identity, restoring a previous session if available.

Promise<Identity>


isAuthenticated(): boolean

Defined in: auth-client.ts:210

Checks whether the user has an active, non-expired session.

boolean


login(options?): Promise<void>

Defined in: auth-client.ts:234

Opens the identity provider and requests a delegation.

AuthClientLoginOptions

Login options.

Promise<void>

When authentication fails and no onError callback is provided.

await authClient.login({
onSuccess: () => console.log('Logged in!'),
onError: (err) => console.error(err),
});

logout(options?): Promise<void>

Defined in: auth-client.ts:287

Clears the stored session and resets the client to an anonymous state.

Logout options.

string

URL to navigate to after logout.

Promise<void>