Understanding the SDK Usage
Code walkthrough explaining SDK initialization, authentication flow, callback handling, user data retrieval, and error handling in the newsletter app.
SDK Initialization
import { HumanitySDK } from '@humanity-org/connect-sdk'
import { getConfig } from './config'
let sdkInstance: HumanitySDK | null = null
export function getHumanitySdk(): HumanitySDK {
if (sdkInstance) {
return sdkInstance
}
const config = getConfig()
sdkInstance = new HumanitySDK({
clientId: config.humanity.clientId,
redirectUri: config.humanity.redirectUri,
environment: config.humanity.environment,
clientSecret: config.humanity.clientSecret,
})
return sdkInstance
}Key Configuration Parameters:
The OAuth Flow
Step 1: Building the Authorization URL
What the SDK Returns:
Step 2: Handling the OAuth Callback
What the SDK Returns:
Step 3: Extracting User Data with the SDK
SDK Methods Used:
Step 4: Using the Query Engine for Complex Conditions
SDK Method:
Key Files Where SDK is Used
File
Purpose
SDK Methods Used
Data Flow Summary
Important Security Notes
Last updated