Your app authenticates
Use your existing session, SSO, magic link, or account system.
Guide · Identity
Phase twoOur Impact does not replace your authentication. Your server confirms who is signed in, then exchanges that trusted identity for a short-lived browser token.
Use your existing session, SSO, magic link, or account system.
Send the same stable external user ID every time that customer returns.
A 60–3600 second token permits browser reads for only that user and project.
The external ID is the join between your customer record and their Our Impact activity.
usr_01JABC.storefront:usr_01JABC.The identity route belongs in your application. It verifies your existing session and calls POST /api/v1/identity-tokens from the server.
import { OurImpactClient } from "@our-impact/node";
import { auth } from "@/lib/auth";
const ourImpact = new OurImpactClient({
secretApiKey: process.env.OUR_IMPACT_SECRET_KEY,
});
export async function POST() {
const session = await auth();
if (!session?.user?.id) {
return Response.json({ error: "unauthorized" }, { status: 401 });
}
const identity = await ourImpact.identity.createIdentityToken({
body: {
externalUserId: "storefront:" + session.user.id,
displayName: session.user.name ?? undefined,
ttlSeconds: 900,
},
});
return Response.json(identity);
}{
"token": "oi_identity_opaque_value",
"expires_at": "2026-11-11T08:15:00.000Z",
"user": {
"external_user_id": "storefront:usr_01JABC",
"display_name": "Avery"
}
}The browser SDK mounts the hosted campaign, supplies the same identity token, and follows content height without a nested scrollbar.
import { OurImpact } from "@our-impact/browser";
const impact = new OurImpact({
publishableKey: "oi_pk_test_...",
userToken: identity.token,
});
const campaign = impact.widgets.mountCampaign({
target: "#our-impact-campaign",
publicId: "your-campaign-id",
height: "auto",
});
// When your signed-in customer changes:
impact.setIdentity(nextIdentityToken);
// During view cleanup:
campaign.destroy();The widget still validates that the host origin appears in the project’s allowed-origin list. Use a numeric height only when you intentionally want a fixed, scrollable frame.
Tokens expire by design. Treat them like a short-lived projection of your application session, not a new login system.
async function signInToOurImpact() {
const response = await fetch("/api/our-impact/identity", { method: "POST" });
if (!response.ok) throw new Error("Could not identify supporter");
const identity = await response.json();
impact.setIdentity(identity.token);
}
function onSignedOut() {
impact.clearIdentity();
}setIdentity().clearIdentity() before showing another session.setIdentity() again. Never persist the token as a durable account credential.