> ## Documentation Index
> Fetch the complete documentation index at: https://docs.passage.coinlist.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Set up OAuth authentication

> Authenticate users with Passage and authorize your application using OAuth 2.0 with PKCE and a backend session.

Users authenticate with Passage and authorize your application - no passwords are shared with you. Passage uses OAuth 2.0 with PKCE (Proof Key for Code Exchange) to secure the redirect flow.

This page assumes you run a **backend** you control: the **client secret**, refresh token, and token exchange stay on the server. The React SDK handles PKCE in the browser and session hydration through `getAccessToken`.

A user with no CoinList account can [sign in with their wallet](https://docs.passage.coinlist.co/sdk/wallet-sign-in.md) instead. That setup builds on this page.

## Prerequisites

* A registered `client_id` and `redirect_uri` from Passage - [contact us](mailto:support@coinlist.co) if you need access
* `redirect_uri` must match your OAuth callback page (for example `https://your-domain.com/oauth/coinlist/callback`)
* `client_secret` available **only** on the server
* `@passage-cl/react` installed ([SDK quickstart](https://docs.passage.coinlist.co/sdk/quickstart.md))

The [partner-demo](https://github.com/coinlist/partner-demo) app shows a full integration. It can lag the latest SDK release, so where the two differ, follow this page.

## Wrap your app with PassageProvider

Configure `clientId`, `redirectUri`, and `getAccessToken` so the SDK can run OAuth in the browser and read short-lived access tokens from your session API.

```tsx theme={null}
// app/providers.tsx
"use client";

import { PassageProvider } from "@passage-cl/react";
import type { ClientConfig } from "@passage-cl/react";
import { ClientId, RedirectUri } from "@passage-cl/react/universal";
import type { SignInMethod } from "@passage-cl/react/universal";

// Module scope: the provider builds a new client whenever `config` changes
// identity, so do not rebuild it on every render.
const config: ClientConfig = {
  clientId: ClientId(process.env.NEXT_PUBLIC_COINLIST_CLIENT_ID!),
  redirectUri: RedirectUri(process.env.NEXT_PUBLIC_COINLIST_REDIRECT_URI!),
  getAccessToken: async () => {
    const res = await fetch("/api/coinlist/oauth/access-token", {
      credentials: "include",
    });
    // 204: there is no session.
    if (res.status === 204) return null;
    // Anything else that is not a token: the SDK could not find out. Throw.
    if (!res.ok) {
      throw new Error("GET /api/coinlist/oauth/access-token failed");
    }
    const data = (await res.json()) as {
      value: string;
      expiresAt: string;
      signInMethod: SignInMethod;
    };
    return {
      value: data.value,
      expiresAt: new Date(data.expiresAt),
      signInMethod: data.signInMethod,
    };
  },
  onSessionExpired: async () => {
    // The user's session ended: send them back to sign in.
    window.location.assign("/?session=expired");
  },
};

export function Providers({ children }: { children: React.ReactNode }) {
  return <PassageProvider config={config}>{children}</PassageProvider>;
}
```

Return the token whole, `signInMethod` included. [Keep the sign-in method on the token](#keep-the-sign-in-method-on-the-token) says why.

`getAccessToken` has two answers, and the SDK treats them differently:

* **Resolve `null`** when there is no session, for example when your endpoint answers 204. The SDK treats the user as logged out.
* **Throw** when you could not find out, for example on a 5xx or a network failure. The SDK keeps its current auth state and fails only the request in hand.

Never answer `null` for your own backend's failures: that turns every outage into a sign-out.

The SDK asks `getAccessToken` when it initializes (or on its first request, if that comes first), and again when the API refuses the token it holds with a 401. It does not track `expiresAt` itself. Concurrent requests that need a new token share one call. A `null` after a 401, or the very token the API just refused, is only a suspicion: the SDK waits one second and asks once more, and only a second such answer signs the user out. That second answer also calls `onSessionExpired`, if the user had been logged in. It is called on the next microtask and not awaited, and a rejection is logged and dropped. It never fires on `auth.logout()`, a 5xx, a timeout or a network failure.

`passage.auth.getState()` returns an `AuthState`: `{ type: 'unknown' }`, `{ type: 'logged-out' }`, or `{ type: 'logged-in', signInMethod }`. `passage.init()` resolves to the same object. Since v0.17.0 it is an object rather than a string, so compare `getState().type === 'logged-in'`. In plain JavaScript, the old `getState() === 'logged-in'` is silently always false. In React, `usePassage().authState` holds the same value and re-renders your component when it changes.

If `getAccessToken` throws while the SDK initializes, `passage.init()` rejects with that error and the auth state stays `{ type: 'unknown' }`. `PassageProvider` still sets `isReady` to `true`, so in React `isReady` can be `true` while `passage.auth.getState().type` is `'unknown'`.

> [!NOTE]
>
> Leave `baseUrl` and `tokensBaseUrl` out of `ClientConfig` to use the production defaults. An empty or whitespace-only value throws a `ValidationError` when the client is built (in React, from `PassageProvider`'s render), so omit the field rather than passing an environment variable that is set but empty.
>
> `coinlistBaseUrl` is the CoinList web app that `auth.startOAuth()` redirects to and `passage.requirements.handle` opens. Leave it out too, for production. It is not validated, so an empty value sends the user to a path on your own site. Since v0.15.2 the SDK joins it to the page path with exactly one slash, so a trailing slash in the value does no harm and a path prefix is kept.

Since v0.11.0 the provider also takes a `locale`, a BCP-47 tag applied to number, date and currency formatting in every SDK component in the tree. It defaults to `'en-US'`, a fixed constant rather than `navigator.language`, so server and client render the same markup.

It does not reach embedded third-party flows. The Sumsub identity-verification UI takes its language from [`identityVerificationOptions.locale`](https://docs.passage.coinlist.co/sdk/requirements#props) on `RequirementsChecklistContainer`, and falls back to Sumsub's own default when you omit it.

```tsx theme={null}
<PassageProvider config={config} locale={params.locale}>{children}</PassageProvider>
```

## Sign-in UI (recommended)

Use the packaged sign-in card inside any subtree that already has `PassageProvider`. It calls `passage.auth.startOAuth()` when the user clicks **Continue with CoinList**. Pass `onSignIn` to override that.

```tsx theme={null}
"use client";

import { CoinListSignInCardContainer } from "@passage-cl/react";

export function SignInPanel() {
  return <CoinListSignInCardContainer />;
}
```

If you want the button without the card around it, render `CoinListSignInButton` instead. It has no default action, so pass an `onClick` that calls `passage.auth.startOAuth()`, as in [custom sign-in control](#lower-level-and-custom-integrations).

You do not import any CSS: every SDK component injects its own styles, scoped to the component, when it renders.

For auth gating and pre-fetching offers after sign-in, see [partner-demo `src/app/page.tsx`](https://github.com/coinlist/partner-demo/blob/main/src/app/page.tsx).

## Server: PassageServer and session storage

Create a small factory that binds `createPassageServer` to your outgoing response and session store. The example below uses HTTP-only cookies; adjust to your security model.

```ts passage-server.ts theme={null}
// lib/passage-server.ts
import type { NextResponse } from "next/server";
import type { PassageServer } from "@passage-cl/react/server";
import { createPassageServer } from "@passage-cl/react/server";
import {
  ClientId,
  ClientSecret,
  RedirectUri,
} from "@passage-cl/react/universal";
import { createSessionCookiesStore } from "./session-store";

export function passageServer(outgoingResponse: NextResponse): PassageServer {
  return createPassageServer({
    clientId: ClientId(process.env.NEXT_PUBLIC_COINLIST_CLIENT_ID!),
    clientSecret: ClientSecret(process.env.COINLIST_CLIENT_SECRET!),
    redirectUri: RedirectUri(process.env.NEXT_PUBLIC_COINLIST_REDIRECT_URI!),
    sessionStore: createSessionCookiesStore(outgoingResponse),
  });
}
```

```ts session-store.ts theme={null}
// lib/session-store.ts
import { cookies } from "next/headers";
import { NextResponse } from "next/server";
import type { SessionStore } from "@passage-cl/react/server";
import type { OAuthSession, SignInMethod } from "@passage-cl/react/universal";
import { OAuthRefreshToken } from "@passage-cl/react/universal";

const COINLIST_SESSION_COOKIE = "coinlist_session";

/** Copy Set-Cookie headers from the SDK scratch response onto the response you return (e.g. after refresh in `auth.getAccessToken()`). */
export function copyCookiesFromTo(source: NextResponse, target: NextResponse) {
  for (const cookie of source.cookies.getAll()) {
    const { name, value, ...options } = cookie;
    target.cookies.set(name, value, options);
  }
}

export function createSessionCookiesStore(
  outgoingResponse: NextResponse,
): SessionStore {
  return {
    async getSession(): Promise<OAuthSession | null> {
      const raw = (await cookies()).get(COINLIST_SESSION_COOKIE)?.value;
      if (!raw) return null;

      let parsed: {
        accessToken?: {
          value?: string;
          expiresAt?: string;
          signInMethod?: SignInMethod;
        };
        refreshToken?: string;
      };
      try {
        parsed = JSON.parse(raw);
      } catch {
        return null;
      }

      if (!parsed.accessToken?.value || !parsed.accessToken?.expiresAt)
        return null;
      const expiresAt = new Date(parsed.accessToken.expiresAt);
      if (Number.isNaN(expiresAt.getTime())) return null;

      return {
        accessToken: {
          value: parsed.accessToken.value,
          expiresAt,
          // A session stored before v0.17.0 has none: it is a CoinList login.
          signInMethod: parsed.accessToken.signInMethod ?? { method: "coinlist" },
        },
        ...(parsed.refreshToken
          ? { refreshToken: OAuthRefreshToken(parsed.refreshToken) }
          : {}),
      };
    },

    async setSession(session: OAuthSession | null): Promise<void> {
      if (session == null) {
        outgoingResponse.cookies.delete(COINLIST_SESSION_COOKIE);
        return;
      }

      outgoingResponse.cookies.set(
        COINLIST_SESSION_COOKIE,
        JSON.stringify({
          accessToken: {
            value: session.accessToken.value,
            expiresAt: session.accessToken.expiresAt.toISOString(),
            signInMethod: session.accessToken.signInMethod,
          },
          ...(session.refreshToken
            ? { refreshToken: String(session.refreshToken) }
            : {}),
        }),
        {
          httpOnly: true,
          secure: process.env.NODE_ENV === "production",
          sameSite: "lax",
          path: "/",
        },
      );
    },
  };
}
```

### Keep the sign-in method on the token

Every access token carries a `signInMethod`: `{ method: "coinlist" }` for a CoinList login, or `{ method: "wallet", wallet }` for a wallet sign-in. CoinList's token responses don't say how a token was obtained, so the SDK carries the field itself, and your code has to keep it in four places:

* **`getSession`** reads it back, with `{ method: "coinlist" }` for a session stored before v0.17.0.
* **`setSession`** writes it.
* **The [access-token endpoint](#serve-access-tokens-to-the-client)** serves it.
* **`getAccessToken`** in your `ClientConfig` returns it.

TypeScript catches a `getSession` or `getAccessToken` that leaves it out, but not a `setSession` or an endpoint that does.

A token without the field reads as a CoinList login and logs a warning, so upgrading signs no one out. A wallet session that loses it reads as a CoinList login too: CoinList refuses it on CoinList-only requests, and the SDK never signs it out when its wallet disconnects or changes.

### Read-only session stores (Server Components)

In Next.js **Server Components** you can read cookies but cannot write them, so a writable `SessionStore` is unsafe - a refreshed session would be silently discarded after consuming the refresh token, effectively logging the user out. Since v0.5.1, `setSession` is **optional**: omit it to opt into read-only mode explicitly.

```ts passage-server-readonly.ts theme={null}
// lib/passage-server-readonly.ts
import { cookies } from "next/headers";
import type { SessionStore } from "@passage-cl/react/server";
import { createPassageServer } from "@passage-cl/react/server";
import type { OAuthSession } from "@passage-cl/react/universal";
import {
  ClientId,
  ClientSecret,
  RedirectUri,
} from "@passage-cl/react/universal";

// Read-only store: only `getSession`, no `setSession`.
const readOnlySessionStore: SessionStore = {
  async getSession(): Promise<OAuthSession | null> {
    const raw = (await cookies()).get("coinlist_session")?.value;
    // …parse and return, same as the writable store above
    return parseSession(raw);
  },
};

export function passageServerForRSC() {
  return createPassageServer({
    clientId: ClientId(process.env.NEXT_PUBLIC_COINLIST_CLIENT_ID!),
    clientSecret: ClientSecret(process.env.COINLIST_CLIENT_SECRET!),
    redirectUri: RedirectUri(process.env.NEXT_PUBLIC_COINLIST_REDIRECT_URI!),
    sessionStore: readOnlySessionStore,
  });
}
```

What the SDK does in read-only mode:

* **`auth.getAccessToken()`** returns the stored token as-is, even if it has expired, and logs a warning. It never refreshes, so no refresh token is consumed. A non-null token is not a promise that the API accepts it: check `token.expiresAt > new Date()` before relying on it.
* **API requests** are sent with the stored token. If the API refuses it with a 401, the SDK returns that error without trying to refresh.
* **`auth.completeOAuth()` and `auth.logout()`** reject with `WritableSessionStoreRequiredError` before any network request. Use a writable store in your Route Handlers for those flows.
* **`passage.tokens`** still works. It is unauthenticated, so token metadata reads need no session at all.

> [!WARNING]
>
> Don't fake a writable store with a no-op `setSession: async () => {}`. That used to be the workaround for Server Components, but it silently consumed refresh tokens during a refresh attempt and logged the user out. If you upgrade from a pre-0.5.1 version, **remove** any no-op `setSession` you added. See the [v0.5.1 changelog](https://docs.passage.coinlist.co/changelogs/react.md#v0-5-1) for the full migration note.

Use the writable cookie store (above) inside **Route Handlers** for `auth.completeOAuth`, `auth.getAccessToken()`-driven refresh, and `auth.logout`. Use the read-only store inside **Server Components** for plain reads (for example, pre-fetching offers with `passage.offers.list()` for SSR).

## Callback route

On the URL you registered as `redirect_uri`, use **`useCompleteOAuth`**: it validates the redirect (state / PKCE via `passage.auth.completeOAuth`), hands the code to your `postOAuthComplete` to exchange on your backend, then runs `passage.init()` so the client picks up the new session. If `postOAuthComplete` returns `false` or rejects, or `passage.init()` rejects, `onFailure` receives `"complete_request_failed"`.

This matches [partner-demo `src/app/oauth/coinlist/callback/page.tsx`](https://github.com/coinlist/partner-demo/blob/main/src/app/oauth/coinlist/callback/page.tsx):

```tsx theme={null}
// app/oauth/coinlist/callback/page.tsx
"use client";

import { useCompleteOAuth } from "@passage-cl/react";
import type { CompleteOAuthFailureReason } from "@passage-cl/react";
import { useRouter } from "next/navigation";

export default function CoinListCallbackPage() {
  const router = useRouter();

  useCompleteOAuth({
    async postOAuthComplete({ code, codeVerifier }) {
      const res = await fetch("/api/coinlist/oauth/complete", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        credentials: "include",
        body: JSON.stringify({ code, codeVerifier }),
      });
      return res.ok;
    },
    onFailure(reason: CompleteOAuthFailureReason) {
      router.replace(`/?error=${encodeURIComponent(reason)}`);
    },
    onSuccess() {
      router.replace("/");
    },
  });

  return (
    <div className="flex min-h-screen items-center justify-center">
      <p>Completing sign-in…</p>
    </div>
  );
}
```

> [!NOTE]
>
> Put this file at a path that matches `NEXT_PUBLIC_COINLIST_REDIRECT_URI`. Read the `error` query parameter on your home page (for example via `useSearchParams`) if you want to show OAuth errors - see [partner-demo `src/features/login/useLoginViewModel.tsx`](https://github.com/coinlist/partner-demo/blob/main/src/features/login/useLoginViewModel.tsx).

## Exchange the code on your backend

The server SDK performs the token exchange - you do not call the token URL with raw `fetch` in application code. `auth.completeOAuth` takes an `AuthorizationGrant` (`{ code, codeVerifier }`, exported from `@passage-cl/react/universal`), the same pair the browser's `passage.auth.completeOAuth()` returns. It throws `HttpError` if CoinList refuses the exchange, and it never retries it, because an authorization code is single-use.

```ts theme={null}
// app/api/coinlist/oauth/complete/route.ts
import { NextResponse } from "next/server";
import { AuthorizationCode, CodeVerifier } from "@passage-cl/react/universal";

import { passageServer } from "@/lib/passage-server";

interface CompleteOAuthRequest {
  code: string;
  codeVerifier: string;
}

export async function POST(req: Request) {
  const body: CompleteOAuthRequest = await req.json();
  const { code, codeVerifier } = body;

  if (typeof code !== "string" || typeof codeVerifier !== "string") {
    return NextResponse.json({ error: "missing_fields" }, { status: 400 });
  }

  const response = NextResponse.json({ ok: true });

  await passageServer(response).auth.completeOAuth({
    code: AuthorizationCode(code),
    codeVerifier: CodeVerifier(codeVerifier),
  });

  return response;
}
```

## Serve access tokens to the client

The browser SDK's `getAccessToken` calls this route. Implement it with `passageServer(response).auth.getAccessToken()` so refresh happens server-side. Map its two outcomes the same way the browser reads them: `null` means there is no session (answer 204), and a throw means the SDK could not find out (answer a 5xx, so the browser keeps the user signed in and retries later). Serve `signInMethod` with the rest of the token: this is one of the places that [keeps it](#keep-the-sign-in-method-on-the-token), and the compiler can't tell you if you leave it out.

```ts theme={null}
// app/api/coinlist/oauth/access-token/route.ts
import { passageServer } from "@/lib/passage-server";
import { copyCookiesFromTo } from "@/lib/session-store";
import type { OAuthAccessToken } from "@passage-cl/react/universal";
import { NextResponse } from "next/server";

export async function GET() {
  const cookieSink = new NextResponse(null, { status: 204 });
  let token: OAuthAccessToken | null;
  try {
    token = await passageServer(cookieSink).auth.getAccessToken();
  } catch (error) {
    // CoinList's token endpoint or the network failed. Not a logout.
    console.error(error);
    return new NextResponse(null, { status: 503 });
  }
  if (token == null) {
    return cookieSink;
  }

  const response = NextResponse.json({
    value: token.value,
    expiresAt: token.expiresAt.toISOString(),
    signInMethod: token.signInMethod,
  });
  copyCookiesFromTo(cookieSink, response);
  return response;
}
```

> [!NOTE]
>
> When `auth.getAccessToken()` refreshes the session, the SDK may set cookies on `cookieSink`. `copyCookiesFromTo` applies those to the JSON response so the browser gets the updated session cookie.

### How the server refreshes

With a writable store, `auth.getAccessToken()` refreshes the session once the access token is within `accessTokenExpiryBufferSeconds` of its expiry (default 60 seconds). To change it, pass `accessTokenExpiryBufferSeconds: Seconds.of(120)` to `createPassageServer`, with `Seconds` from `@passage-cl/react/universal`. `Seconds.of` throws a `ValidationError` unless its argument is a non-negative integer.

* **Concurrent requests share one refresh.** All `PassageServer` instances in one process (one JavaScript module instance) that refresh the same session join a single `POST /oauth/token`, and each writes the result to its own `SessionStore`.
* **A rejected refresh token is a suspicion first.** CoinList answers a refresh that lost a race to a concurrent request the same way it answers a dead session (`400 invalid_grant`). On the first rejection the SDK writes nothing and returns `null`, or the current access token if it has not actually expired yet.
* **A second rejection is the verdict.** When the same process sees the same refresh token rejected again, 5 to 60 seconds after the first, the SDK clears the session with `setSession(null)` and then calls the server's `onSessionExpired`. A session that has no refresh token is served until it actually expires, then cleared the same way.
* **A failure to find out never clears the session.** On a 5xx, a network failure, `invalid_client` or an unreadable response, the SDK keeps serving the current access token if it has not expired yet, and logs a warning. If it has expired, `auth.getAccessToken()` throws the underlying error (`HttpError`, or the `fetch` error) and leaves the session untouched. Other `PassageServer` methods that need a session throw that same error instead of `NotAuthenticatedError`.
* **A 401 forces a refresh.** If the API refuses a token that still looks valid locally, for example a session revoked elsewhere, a writable store refreshes anyway.
* **An invalid `expiresAt`** in the session your store returns makes `auth.getAccessToken()` throw a `ValidationError`.

`onSessionExpired` on `ServerConfig` fires at most once per session per process within 60 seconds, so make it idempotent. When the browser drives renewal through your access-token route, it reaches its own verdict one second after the first rejection, so expect the browser's `onSessionExpired` rather than the server's.

## Log out

Clear the session with the server SDK from a route handler. `auth.logout()` revokes the token with `POST /oauth/revoke` and clears the session through `setSession(null)`. It does nothing when there is no session. Your OAuth client needs the `revoke` grant type: without it every revoke fails, and the token stays valid until it expires.

```ts theme={null}
// app/api/coinlist/oauth/logout/route.ts
import { passageServer } from "@/lib/passage-server";
import { NextResponse } from "next/server";

export async function POST() {
  const response = NextResponse.json({ ok: true });
  await passageServer(response).auth.logout();
  return response;
}
```

The revoke is best-effort. If it fails for any reason - an `HttpError`, a network failure, anything else - the SDK logs a warning and clears the session anyway, because the cleared session is what logs the user out. Set `strict: true` on `createPassageServer` to rethrow the revoke failure instead, leaving the session in place so you can retry. In both modes, an error thrown by your `SessionStore` propagates, and a read-only store rejects with `WritableSessionStoreRequiredError`.

Call `passage.auth.logout()` on the client to drop the in-memory token after the server clears the session. It is synchronous, it never calls `onSessionExpired`, and it wins over a `getAccessToken` answer that was already in flight, so a late answer cannot sign the user back in.

## Token management

* **Access tokens** are short-lived. The SDK attaches them as `Authorization: Bearer` on API requests.
* **Refresh tokens** are long-lived. Keep them on the server. With the server SDK and a writable store, `auth.getAccessToken()` refreshes them for you (see [how the server refreshes](#how-the-server-refreshes)).
* Never expose **`client_secret`** or long-lived refresh tokens to the browser bundle.

## Lower-level and custom integrations

Use the sections below only if you are not using the defaults above.

> [accordion] Custom sign-in control (usePassage + startOAuth)
>
> If you build your own button or entry point, call `auth.startOAuth()` from `usePassage()`:
>
> ```tsx theme={null}
> "use client";
>
> import { usePassage } from "@passage-cl/react";
>
> export function LoginButton() {
>   const { passage } = usePassage();
>
>   return (
>     <button type="button" onClick={() => void passage.auth.startOAuth()}>
>       Continue with CoinList
>     </button>
>   );
> }
> ```

> [accordion] Manual callback handling (auth.completeOAuth + fetch)
>
> You can call `passage.auth.completeOAuth()` yourself, then POST `code` and `codeVerifier` to `/api/coinlist/oauth/complete`, await `passage.init()`, and redirect. `completeOAuth()` returns an `OAuthClientResult`: either `{ type: "ok", code, codeVerifier }` or `{ type: "error", reason }`, where `reason` is an `OAuthClientErrorReason`. Prefer `useCompleteOAuth` when possible - it centralizes failure reasons and avoids duplicate work in React Strict Mode.
>
> ```tsx theme={null}
> "use client";
>
> import { usePassage } from "@passage-cl/react";
> import { useRouter, useSearchParams } from "next/navigation";
> import { Suspense, useEffect, useRef } from "react";
>
> function LegacyCallbackBody() {
>   const { passage } = usePassage();
>   const searchParams = useSearchParams();
>   const router = useRouter();
>   const hasStarted = useRef(false);
>
>   useEffect(() => {
>     if (hasStarted.current) return;
>
>     if (searchParams.get("error")) {
>       router.replace("/?error=coinlist_denied");
>       return;
>     }
>
>     if (!searchParams.get("code")) return;
>
>     const oauthRes = passage.auth.completeOAuth();
>     if (oauthRes.type === "error") {
>       router.replace("/?error=coinlist_oauth");
>       return;
>     }
>
>     hasStarted.current = true;
>
>     void (async () => {
>       const res = await fetch("/api/coinlist/oauth/complete", {
>         method: "POST",
>         headers: { "Content-Type": "application/json" },
>         credentials: "include",
>         body: JSON.stringify({
>           code: oauthRes.code,
>           codeVerifier: oauthRes.codeVerifier,
>         }),
>       });
>
>       if (!res.ok) {
>         hasStarted.current = false;
>         router.replace("/?error=coinlist_complete_failed");
>         return;
>       }
>
>       try {
>         await passage.init();
>       } catch {
>         hasStarted.current = false;
>         router.replace("/?error=coinlist_init_failed");
>         return;
>       }
>       router.replace("/");
>     })();
>   }, [passage, searchParams, router]);
>
>   return <p>Completing sign-in…</p>;
> }
>
> export default function LegacyCallbackPage() {
>   return (
>     <Suspense fallback={<p>Completing sign-in…</p>}>
>       <LegacyCallbackBody />
>     </Suspense>
>   );
> }
> ```

> [accordion] Imperative client (createPassageClient)
>
> For non-React browser code, import `createPassageClient` and `ClientConfig` from `@passage-cl/react` and call the same namespaces (`passage.auth.startOAuth()`, `passage.auth.completeOAuth()`, `passage.offers.list()`, …). Without `PassageProvider`, call `await passage.init()` yourself before relying on `passage.auth.getState()`. It rejects with whatever your `getAccessToken` throws, leaving the state `{ type: 'unknown' }`. You still need a backend for token exchange in production.

## Next step

> [card] [Fetch offers](https://docs.passage.coinlist.co/sdk/fetch-offers.md)
>
> List offers for the signed-in user with `OffersGridContainer` or hooks, then open [Display offer details](https://docs.passage.coinlist.co/sdk/sale-details.md) for one offer.

## Resources

* [OAuth 2.0 Playground](https://oauth.net/playground/)
* [PKCE authorization code flow (Auth0)](https://auth0.com/docs/get-started/authentication-and-authorization-flow/authorization-code-flow-with-pkce)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.