Skip to Content
The AKIN Travel developer platform is in beta — APIs may change. Get started →
Authentication

Authentication

AKIN Travel auth is built on Google Identity Platform (GIP) / Firebase. Members sign in through one of three flows; each ends with a Firebase ID token that you send as Authorization: Bearer <idToken> on every member-scoped request.

On React, <AkinProvider> runs this entire exchange for you. On any other stack you drive the same GraphQL mutations and finish with the Firebase Auth SDK (web, Android, and iOS all have one).

Partner API keys: publishable vs secret

Every request carries your partner API key in the x-partner-api-key header. Keys come in two classes — pick the right one for where the key will live:

Key classWhere it livesCapability
Publishable (browser-safe)Shipped to the browser — React bundle, <script data-api-key> embed, page sourceRead-only by construction. It can start auth flows and read loyalty state, but it can never carry or exercise a write scope.
SecretYour server only — never in a browserFull capability. Grant it the scopes your backend needs (member:write to enrol, loyalty:write to earn/burn points).

The class shows in the prefix, and each class exists for both environments:

Key classSandboxProduction
Publishablepk_test_*pk_live_*
Secretsk_test_*sk_live_*

You choose the class when you create the key in the dashboard (a publishable key is flagged browser-safe; a secret key is the default).

Older secret keys start with pk_. A secret key created before this change reached production carries a pk_test_* / pk_live_* prefix. It keeps working unchanged. When you rotate it in the dashboard, the replacement is issued as sk_*. Until then, treat it as secret: the class you chose when you created it decides what it can do, not its prefix.

Scan for leaked secret keys. Add the custom pattern sk_(live|test)_[0-9a-f]{64} to GitHub secret scanning (repository or organisation Settings → Code security → Secret scanning → Custom patterns) and to any other scanner you run, so that a secret key committed to a repository is flagged.

Why it matters. A publishable key is safe to expose precisely because it’s read-only — even if a page visitor reads it out of your bundle, they can’t write. The API enforces this on both ends: a publishable key cannot be created with a write scope, and a write operation attempted with a publishable key is rejected server-side. Never ship a secret key to the browser; if you have, rotate it in the dashboard.

Key scopes

A scope is a capability a key holds. You select a key’s scopes when you create or edit it in the dashboard (Developers → API keys).

ScopeWhat it allowsKey class
loyalty:readReserved for loyalty reads. No operation checks it today; the loyalty reads work with any keyPublishable or secret
member:readThe server-to-server member reads (memberByEmail, memberByExternalId, …)Publishable or secret
loyalty:writeEarn and burn pointsSecret only
member:writeEnrol membersSecret only
reporting:readThe Partner Reporting API: arrivals, sign-ups and headline figures, with member email under the reporting privacy rulesSecret only, and only when AKIN has granted reporting to your partner

A key with an empty scope list keeps every read scope except reporting:read. A key with an explicit list has exactly the scopes it names.

A secret key no longer reads tier only. Before the Partner Reporting API, a server-to-server key read a member’s tier and nothing about the member’s stays or points. A secret key that holds reporting:read also reads your arrivals (with the points balance of your own enrolled members), your sign-ups and your figures. Keep it on your server, and rotate it in the dashboard if it leaks.

Use a publishable key for the browser SDKs (React quickstart, embed widget) and a secret key for the server SDK and any server-to-server write.

Supported sign-in flows

FlowWhen to useAPI mutationSDK shortcut
Magic linkLowest friction for new members — a one-time link by email.requestMagicLink → verifyAuthToken<MagicLinkForm>
PasskeyBest UX once a device is enrolled. WebAuthn under the hood.passkeyAuthenticationOptions → passkeyAuthenticate<LoginForm> (auto-detects)
Email + passwordOptional fallback when your audience expects passwords.loginMemberGIP<LoginForm>, <SignupForm>

All flows return the same member shape, and steps 2–3 below are identical regardless of which one you start with.

The exchange (any stack)

  1. Start a flow — e.g. requestMagicLink(email, userType: "MEMBER", partnerId, redirectUrl). Authenticated with your x-partner-api-key; no member token yet.
  2. Verify — verifyAuthToken(token) returns { customToken, userId, isNewUser, memberData }. The customToken is a short-lived Firebase custom token.
  3. Sign in to Firebase — pass customToken to signInWithCustomToken (Firebase web/Android/iOS SDK). Firebase issues an ID token and refreshes it automatically.
  4. Call the API — attach Authorization: Bearer <idToken> to each GraphQL request.

See the Quickstart for runnable React / Vue / Android / iOS / cURL versions.

Sessions

The React SDK keeps the ID token in memory and refreshes it on demand via setTokenProvider; Apollo picks it up through the createAkinClient link, so you rarely call setTokenProvider yourself. Sign-out clears the in-memory token and the GIP session:

const { signOut } = useAkinAuth(); await signOut();

Off React, the Firebase Auth SDK owns the session: getIdToken() returns a fresh token (refreshing as needed) and signOut() clears it.

Your app already signs users in

If your app has its own login and you only want a member’s AKIN Travel loyalty state, you do not need an AKIN session. There is no way to swap your own user ID for an AKIN token, and you do not need one.

Instead, read the member from your server:

  • Call memberByEmail or memberByExternalId server-to-server, with a secret partner key (sk_test_* / sk_live_*) that holds member:read. A publishable key is refused on both.
  • Never ship the secret key in an app or a page. Your app asks your backend, and your backend asks AKIN.
  • Send only an email address that your own login has verified. The lookup trusts the address you send.
  • The read answers only for a member who has a qualifying tie to your partner: a current, upcoming or recent stay, or an active enrolment. Any other member returns MEMBER_NOT_FOUND.

Server-to-server reads has the request and response shapes, and Platform support shows the backend-mediated pattern for mobile apps. On Node, the Server SDK wraps both calls.

Guards (React SDK)

Two render-prop guards control conditional UI. They’re for client-side display only — every mutation is also authorised server-side, on every stack.

import { RequireAuth, RequireGuest } from '@akin-travel/partner-sdk'; <RequireAuth fallback={<SignInButton />}> {({ member }) => <ProfileChip member={member} />} </RequireAuth> <RequireGuest fallback={null}> <SignUpBanner /> </RequireGuest>

Errors

Auth error codes (AUTH_REQUIRED, INVALID_TOKEN, TOKEN_EXPIRED, ACCESS_DENIED) are listed in the Error codes reference. Surface the extensions.code to your error UI, never the message — copy may change.

Last updated on