Frontend OAuth with the Connect SDK
Build a React app that authenticates users with Humanity's OAuth flow and gates content based on biometric verification — using the Connect SDK directly without pre-built components.
Build a React app that authenticates users with Humanity's OAuth and gates access based on the isHuman biometric credential.
The Connect SDK gives you three core methods that you can use to control the flow with no pre-built components or abstraction layer.
After this guide you'll have:
A working Vite + React app that runs locally
The complete OAuth + PKCE flow wired up yourself
Biometric credential verification with live status display
A full sandbox test using mock credentials
Use this approach if you want granular control over authentication, need to understand the flow before abstracting it, or are building a custom integration.
Full source
Before you start
You need:
Node 18 or higher
Bun (used throughout this guide)
A Humanity Developer Account to access the Developer Portal and Sandbox Dashboard
If you haven't registered an application yet, follow the Developer Portal setup guide first. You'll need your clientId and redirectUri.
01. Create the project
Create package.json:
Install dependencies:
Create vite.config.ts:
Create tsconfig.json:
Create tsconfig.app.json:
Create tsconfig.node.json:
Create index.html at the project root:
02. Configure the Developer Portal
Go to developers.humanity.org, open your application, and switch to the Sandbox tab in Settings.
Add
http://localhost:5173/oauth/callbackas a redirect URIUnder scopes, enable:
OpenID Connect (
openid) — required for the OAuth flowIdentity Information (
identity:read) — includes Palm Verified credential
03. Generate a sandbox credential
Before testing the flow, generate a mock Palm Vein Biometric Scan credential in the Sandbox Dashboard.
Go to app.sandbox.humanity.org and sign in
Open the Create tab
Search for Palm Vein and select it
04. Set up environment variables
Create .env.local at the project root:
Get these values from the Developer Portal under your application's sandbox settings.
05. Build the app
Create the folder structure:
SDK initialization — src/lib/humanity.ts
Initialize the Connect SDK with your credentials. Stores the PKCE code verifier in localStorage to survive cross-domain OAuth redirects in Firefox and Safari.
Auth context — src/hooks/useAuth.tsx
This context holds your access token, credentials, and metadata. Session storage keeps everything across page reloads during testing.
Button component — src/components/Button.tsx
A reusable button with multiple style variants.
Login button — src/components/LoginButton.tsx
This generates the SDK auth URL with PKCE and stores the code verifier before redirecting to Humanity.
Home page — src/pages/Home.tsx
Display the verification card and redirect authenticated users to the dashboard.
OAuth callback — src/pages/OAuthCallback.tsx
This page handles the redirect back from Humanity. It exchanges your authorization code for an access token and checks for the is_human credential.
Dashboard — src/pages/Dashboard.tsx
Display the biometric status. The is_human credential can be true, false, or missing—the dashboard shows all three.
App routing — src/App.tsx
Entry point — src/main.tsx
Stylesheet — src/index.css
The app uses a plain CSS stylesheet — no Tailwind. All component classes (biometric-status-card, dashboard-shell, home-screen, etc.) and the utility classes used throughout the components are defined here.
06. Run and test
Start the dev server:
Open http://localhost:5173. You should see the home page with a "Verify" button.
Click Verify
Sign in with your sandbox account (the one with the mock
is_humancredential)You'll land on the dashboard showing Human verified
If you test without a credential, the dashboard shows Not verified with value false or missing.

How it works
The whole flow comes down to three SDK methods:
buildAuthUrl()— creates an authorization URL with PKCE. Stores the code verifier in localStorage so it survives Firefox and Safari cross-domain redirects.exchangeCodeForToken()— swaps the authorization code for an access token using the stored verifier.verifyPresets()— checks which credentials the user has. In this case, justis_human.
The app keeps tokens and credential data in session storage. On the dashboard, it pulls out the is_human through isHuman mapping value and displays the result.
Next Steps
Ready to build a more complex application?
The Personalized Newsletter App takes everything you built here and moves it to a full-stack Next.js setup — tokens handled server-side, clientSecret kept out of the browser, and session storage replaced with HTTP-only cookies.
You'll work with batch preset verification, the Query Engine, and MongoDB to build something that actually acts on verified identity: a personalized content feed driven by what Humanity knows about the user.
Last updated