SDK Recipes
Prerequisites
import { HumanitySDK } from '@humanity-org/sdk';
const sdk = new HumanitySDK({
clientId: process.env.HUMANITY_CLIENT_ID!,
redirectUri: process.env.HUMANITY_REDIRECT_URI!,
environment: process.env.HUMANITY_ENVIRONMENT ?? 'sandbox',
clientSecret: process.env.HUMANITY_CLIENT_SECRET, // omit for public clients
});Example 1 — Kick off OAuth with PKCE
Example 2 — Exchange the code and persist the session
Example 3 — Gate features by presets
Example 4 — Poll credential and authorization feeds
Example 5 — Proactively revoke access
Example 6 — Leverage discovery + health endpoints
Example 7 — Generate JWTs with your secret key
Example 8 — Decode JWT payloads
Example 9 — Refresh Humanity tokens
Example 10 — PKCE state and nonce verification
Example 11 — Server-to-server token acquisition
Example 12 — Fetch user profile via preset
Dropping down to the generated client
Last updated