Reference

Web SDK functions, options, errors, scopes, id_token claims and endpoints.

Functions

Function
renderButton(target, options)Draws the "Sign in with Paspo ID" button into target (an element or a selector) and runs signIn on click. Returns a PaspoButton
signIn(options)Starts sign-in. Call it synchronously from a click handler. Returns nothing; results arrive in callbacks
takeVerifier(state)PKCE code_verifier for this attempt. Returns it once, then ""
takeNonce(state)The nonce sent to Paspo. Returns it once, then ""
configure({ origin })npm build only: set a non-default Paspo origin before the first renderButton / signIn
versionSDK version string

With the CDN build these live on window.Paspo (no configure — the origin comes from the script URL).

Button

renderButton takes every signIn option, plus:

OptionType
theme"brand" | "light" | "dark" | "neutral"Default "brand"
cornerRadiusnumber | stringPixels or a CSS length. Default: a pill
iconOnlybooleantrue — a round, logo-only button
showLogobooleanfalse — text only. Ignored with iconOnly

Returns:

interface PaspoButton {
  element: HTMLElement;                   // host element inside the target
  setDisabled(disabled: boolean): void;
  destroy(): void;                        // removes the button and its listener
}

Examples and themes are on the Sign-in button page.

signIn options

OptionType
clientIdstringRequired. Your client ID
redirectUristringRequired. A registered redirect URI on the same origin as the page
scopestringRequired. Space-separated scopes, e.g. "openid email"
fedcmbooleanfalse disables the browser's FedCM prompt. Default: used when possible
mobileAppbooleanfalse keeps iOS and Android on the popup, like a computer. Default: phones go to the Paspo app
onSuccess(result) => voidGot a code. See result
onError(error) => voidSign-in failed. See errors
onClose() => voidThe user closed the Paspo window. A dismissed or failed FedCM prompt doesn't call onClose — the Paspo window opens instead

Calling signIn again while a window is open closes the old one and starts a new attempt. If the FedCM prompt never showed up (no Paspo session in the browser), the second click opens the Paspo window right away.

Result

interface PaspoSignInResult {
  code: string;    // one-time, valid 60 s
  state: string;   // pass to takeVerifier / takeNonce
  via?: "fedcm";   // set when the browser prompt issued the code
}

When via is "fedcm", exchange the code without redirect_uri.

onSuccess is not called when the code arrives at the callback page redirectUri?code=…&state=…:

  • Popup blocked — the tab goes to Paspo and comes back in the same tab. takeVerifier(state) reads this tab's sessionStorage.
  • Phone — the Paspo app opens redirectUri in a new browser tab. takeVerifier(state) reads localStorage, where the value is kept for 15 minutes.

The callback page code is the same for both.

Errors

interface PaspoSignInError {
  error: string;
  error_description: string;
  state?: string;
}
errorWhenWhat to do
invalid_requestMissing clientId / redirectUri / scope, an invalid URL, an insecure context (no crypto.subtle) or blocked sessionStorageFix the options; serve over HTTPS
access_deniedThe user declined on the consent screenLet them try again
otherStandard OAuth error codes passed through from Paspo, e.g. server_errorShow error_description, let the user retry

An unknown client_id or an unregistered redirect_uri is never redirected back to your site: Paspo shows the error in its own window. Check both in your client settings.

Errors from the token endpoint (on your server):

error
invalid_grantThe code expired (60 s), was already used, or code_verifier / redirect_uri don't match. Start a new sign-in
invalid_clientWrong client_id / client_secret
invalid_requestA required parameter is missing
unsupported_grant_typegrant_type isn't authorization_code

Scopes

ScopeClaims in id_tokenNotes
openidsub, iss, aud, exp, iat, nonceAlways include it
profilename
emailemail, email_verifiedThe user picks which address to share
phonephone_number, phone_number_verifiedThe user picks which number to share. phone without email enables the FedCM prompt in Chromium 141+

Request at least one of profile, email, phone.

ID token claims

ClaimType
issstringhttps://paspo.id
substringStable Paspo user ID. Use it as the account key
audstringYour client_id
exp, iatnumberUnix seconds
noncestringThe value from takeNonce(state)
namestringWith profile
emailstringWith email — the address the user chose on the consent screen, not necessarily their primary
email_verifiedbooleanWith email
phone_numberstringWith phone, E.164, e.g. +77001234567
phone_number_verifiedbooleanWith phone

Endpoints

DiscoveryGET https://paspo.id/.well-known/openid-configuration
AuthorizeGET https://paspo.id/oauth/authorize
TokenPOST https://paspo.id/api/w/v1/oauth/token
JWKSGET https://paspo.id/api/w/v1/oauth/jwks
UserInfoGET https://paspo.id/api/w/v1/oauth/userinfo with Authorization: Bearer <access_token>
FedCM confighttps://paspo.id/api/w/v1/fedcm/config.json

Browser storage

On a computer the SDK keeps two sessionStorage entries per attempt and removes them when read or when the attempt ends:

  • paspo.oauth.verifier.<state>
  • paspo.oauth.nonce.<state>

The SDK writes to localStorage in two cases only:

KeyWhenLifetime
paspo.oauth.app.<state>Sign-in through the app on a phone: the verifier and nonce must survive into the new tabRemoved when read; abandoned attempts after 15 minutes
paspo.fedcm.failed.<origin>The FedCM prompt failed — the next clicks open the Paspo window directly24 hours

No cookies, no tracking.

Testing

  1. In development, log the result instead of posting it:
    Paspo.renderButton("#paspo-button", {
      clientId: "YOUR_CLIENT_ID",
      redirectUri: location.origin + "/auth/paspo/callback",
      scope: "openid email",
      onSuccess: ({ code, state }) => console.log({ code, verifier: Paspo.takeVerifier(state) }),
    });
    
  2. Within 60 seconds run the cURL request with these values.
  3. Before release, check:
    • a successful sign-in and cancelling the Paspo window on a computer;
    • a blocked popup — sign-in through the redirect and the callback page;
    • a phone with and without the Paspo app — back to the callback page in a new tab;
    • if you request phone without email — the FedCM prompt in Google Chrome;
    • a reused code — your server must get invalid_grant.

Versioning

The current version is 1.2.0. The npm package follows semver. The CDN file at https://paspo.id/sdk/paspo.min.js always serves the latest compatible 1.x and is cached for one hour.

VersionWhat's new
1.2.0On phones the button opens the Paspo app (mobileApp). A failed FedCM prompt falls back to the Paspo window. The SDK no longer fetches discovery before opening the window
1.1.0The ready-made renderButton
1.0.0signIn, PKCE, the FedCM prompt, redirect fallback