Skip to main content
@gooclaim/aiveth-react adds Aiveth by Gooclaim sign-in to a React single-page app. People sign in on Aiveth’s own page with the authorization code flow and PKCE. Passwords, passkeys, two-step and single sign-on never pass through your app.

Install

Requires React 18 or later.

Set up the app in Aiveth

In the console, go to Apps and register a public app. Add your callback page as its return address, and your sign-out page under its sign-out addresses. The app’s origin may then call Aiveth’s token endpoint. See Single-page apps. Use your Development environment’s app while you build (http://localhost is allowed there), and your production app (HTTPS only) when you ship.

Add the provider

On the return address, the provider finishes the sign-in by itself and cleans the code out of the address bar.

AivethProvider props

string
required
Your Aiveth address. Must be HTTPS (HTTP only for localhost).
string
required
Your app’s client ID.
string
required
Exactly one of the app’s registered return addresses.
string
default:"openid email profile offline_access"
The scopes to ask for.
string
Where Aiveth sends the person after signing out. Register it under the app’s sign-out addresses.
(returnTo: string | null) => void
Called after a return from Aiveth, with where the app wanted to go. Use your router’s navigate here.

useAiveth()

Use it anywhere inside the provider.
On your server, check the access token with the Node or Python SDK’s userFromAccessToken / user_from_access_token.

Components

Acting for others

When a support person acts as someone, the ID token carries act with who and why. Show it, and block what support shouldn’t do:

Feature flags and photos

picture is present with the profile scope.

How tokens are kept

  • Tokens are kept in memory, never in localStorage. After a reload, signIn() comes straight back while the person is still signed in at Aiveth.
  • Refresh tokens (offline_access, asked by default) are swapped for new ones at every use.
  • An access token close to its end is renewed before getAccessToken() returns it.
  • One app belongs to one organization in Aiveth, so there is no organization switcher.

Lower-level client

AivethClient is the class the provider uses. It has signIn, handleRedirect, getAccessToken, signOut, accountUrl and actingUrl, for apps that don’t use the provider.

Errors