Go to developer

Token Exchange

Turn the authorization code into an access_token with PKCE. Paste script and Web SDK do this for you; call it yourself for server-driven flows.

On this page

When exchange runs

Server-driven integrations call exchange on the backend after the browser returns code + state (with the stored code_verifier).

REST

POST/oauth/token
RESTHTTP
POST https://auth.keyra.ie/oauth/token
Content-Type: application/json

{
  "grant_type": "authorization_code",
  "code": "…",
  "code_verifier": "…",
  "redirect_uri": "https://example.com/auth/keyra/callback",
  "client_id": "cp_test_…"
}
FieldRequiredDescription
grant_typeYesauthorization_code
codeYesAuthorization code from hosted UI
code_verifierYesPKCE verifier matching the start challenge
redirect_uriYesSame URI used at start (exact match)
client_idYesPublishable client id

Server SDK

SERVERTypeScript
import { createKeyraServer } from "@keyra/typescript-sdk";

const keyra = createKeyraServer({ baseUrl: "https://auth.keyra.ie" });

const token = await keyra.exchangeAuthorizationCode({
  code,
  code_verifier: codeVerifier,
  redirect_uri: redirectUri,
  client_id: clientId,
});
// token.access_token — alias as verification_token for validate

Response

responsePOST /oauth/token (success)
JSON
{
  "access_token": "…",
  "token_type": "Bearer",
  "expires_in": 3600,
  "user": {
    "id": 123,
    "phone": "+353…",
    "fullName": null,
    "email": null
  }
}

Paste script and Web SDK expose the same value as verification_token / verificationToken for DX. Optional userinfo: User info.

What to do next