Go to developer

Paste Script

Lowest-friction browser path: load keyra-oauth.js, render a KEYRA button, send the verification token to your backend.

On this page

Load the script

BROWSERhtml
<script src="https://auth.keyra.ie/sdk/keyra-oauth.js"></script>

Hosted URL: https://auth.keyra.ie/sdk/keyra-oauth.js. Auth origin defaults to https://auth.keyra.ie.

Required configuration

Every call to attach, renderButton, or completeRedirectCallback needs:

OptionRequiredDescription
authOriginYesKEYRA auth host, e.g. https://auth.keyra.ie
clientIdYesPublishable client id (cp_test_* / cp_prod_*)
redirectUriYesExact match of project callbackUrl or an entry in hosted redirect URIs

Render a button

BROWSERhtml
<div id="keyra-login"></div>
<script src="https://auth.keyra.ie/sdk/keyra-oauth.js"></script>
<script>
  KeyraOAuth.renderButton("#keyra-login", {
    authOrigin: "https://auth.keyra.ie",
    clientId: "cp_test_YOUR_PUBLISHABLE_ID",
    redirectUri: "http://localhost:3000/auth/keyra/callback",
    mode: "auto",
    scope: "verify",
    onSuccess: async function (result) {
      await fetch("/api/auth/keyra", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        credentials: "include",
        body: JSON.stringify({
          verification_token: result.verification_token || result.access_token,
        }),
      });
    },
    onError: function (err) {
      console.error(err);
    },
  });
</script>

What happens here? The script generates PKCE + state, calls POST /verify/start (default scope verify), opens popup or redirect, exchanges the authorization code at POST /oauth/token, then invokes onSuccess.

Success → your backend

responseonSuccess result (shape)
JSON
{
  "access_token": "…",
  "verification_token": "…",  // same value as access_token
  "token_type": "Bearer",
  "expires_in": 3600,
  "user": { /* from token response */ },
  "raw": { /* token endpoint body */ },
  "userinfo": { /* optional if fetchUserinfo */ },
  "userinfoError": null
}

Full validate contract: Server validation.

Methods

MethodPurpose
KeyraOAuth.attach(opts)Wire options to a selector / existing button without forcing appearance.
KeyraOAuth.renderButton(container, opts)Render a styled KEYRA button into a container (selector or element).
KeyraOAuth.completeRedirectCallback(opts)Resume after full-page redirect; completes PKCE exchange using stored verifier.

Options reference

OptionDefaultDescription
modeautoauto | popup | redirect
scopeverifyPassed to POST /verify/start
timeoutMs120000Overall flow timeout (ms)
fetchUserinfotrueAfter token exchange, optionally GET /oauth/userinfo
popupWidth / popupHeight520 / 720Popup window size
autoCompleteRedirecttrueAuto-run redirect callback completion when query params present
button / selectorUsed with attach to bind an existing control
onSuccess / onErrorResult / error callbacks
appearancestyled defaultsObject for button styling, or false to skip rendering chrome

Events & storage

  • Popup completion uses postMessage types KEYRA_AUTH_SUCCESS / KEYRA_AUTH_ERROR with an origin check against authOrigin.
  • Redirect PKCE state is stored under session key keyra:oauth:flow:v2 (not localStorage as your app session).

Appearance

Pass an appearance object, or appearance: false to skip KEYRA button chrome (e.g. when using attach on your own button).

PropertyValues
themeblack | white | outline | icon
sizesmall | medium | large
shaperectangular | pill
textPresets login_with | continue_with | verify_with | signup_with, or a custom string
loadingTextString shown while the flow is in progress
showLogoBoolean
widthCSS width for the control
logoAlignmentLogo placement relative to label
logoUrlOptional custom logo URL
ariaLabelAccessible name override
variablesObject of CSS variable overrides