Installation
Install the Strata SDK with your favorite package manager:Setup
1. Create a signing key in the Strata dashboard
In the Strata dashboard, navigate to the Settings page by selectingSettings in the sidebar. Click Generate New Keypair to get a new signing key. Save the private key somewhere secure. You will not be able to see it again.
2. Create signed user JWT tokens in your app backend
In your app backend, generate a JWT token for each user and make it available to the frontend. If your frontend is a client-side javascript application, this likely means creating an API endpoint that the frontend can use to fetch a user JWT token. Never expose the signing key directly to the frontend. Use the following JWT header claims:- alg: The algorithm used to sign the JWT. Must be
RS256. - typ: The type of token. Must be
JWT.
sub, iat, exp, project_id.
- project_id: Your Strata project ID. This can be found on the Settings page
- sub: The JWT subject. This is your primary identifier for the user.
- iat: The JWT issued at timestamp in seconds since the Unix epoch. Typically the current time.
- exp: The JWT expiration timestamp in seconds since the Unix epoch (must be later than the iat claim).
external_id claim. If provided, it will be used as the user / company identifier and takes precedence over the sub claim.
Here is a sample implementation with a Next.js API endpoint:
3. Prompt a user to authorize your integration
To start the authorization flow for your integration, callstrata.authorize with a signed user jwt. The function call returns a Promise that resolves when the user successfully completes the auth flow. It fails with an error if the authorization fails or the user closes the window without authorizing your app.