πŸ”‘Authentication

In order to utilise our SDK we require all requests to be authenticated. You can view and manage your Separly API keys in the Separly Dashboard.

Your Separly API Key ID acts as your public key, and your Separly Secret API Key acts as the password for the public key. The JWT is an encoded mix of the two. Be sure to keep your secret key private.

How to Create a JWT Token 🧩

Here is sample code to help you create the JWT token using Separly Secret API Key

import { sign, SignOptions } from 'jsonwebtoken';

export function generateToken() {
  // information to be encoded in the JWT
  const payload = {
    partnerId: SEPARLY_API_KEY
  };
  // read private key value
  const privateKey = SEPARLY_SECRET_API_KEY; // replace with the Separly Secret API Key

  const signInOptions: SignOptions = {
    algorithm: 'RS256',
    expiresIn: '12h'
  };

  // generate JWT
  return sign(payload, privateKey, signInOptions);
};

The JWT token you generated will be used in our SDK as an Authorisation header to authenticate all API requests made. It will be passed as a parameter when initialising the Group Buy Flow.

βœ‰οΈ Talk to us!

Our product evolves and improves as you build on top of it, iterating quickly to help support new use cases and constantly optimising for value. To do so effectively, we want your feedback. Any feedback is welcomed - good, bad, or neutral. You can share your input via email to info@separly.com

Last updated