This feature is available in our paid editions. Contact us at sales@activepieces.com, and we'll be delighted to assist you!

You can also book a call here.

Step 1: Obtain Signing Key

You can generate a signing key by going to Platform Settings -> Signing Keys -> Generate Signing Key.

This will generate a public and private key pair. The public key will be used by Activepieces to verify the signature of the JWT tokens you send. The private key will be used by you to sign the JWT tokens.

Note: Please store your private key in a safe place, as it will not be stored in activepieces.

Step 2: Generate a JWT

The signing key will be used to generate JWT tokens for the currently logged-in user on your website, which will then be sent to Activepieces Iframe as a query parameter to authenticate the user.

To generate these tokens, you will need to add code in your backend to generate the token using the RS256 algorithm, so the JWT header would look like this:

{
  "alg": "RS256",
  "typ": "JWT",
  "kid": "SIGNING_KEY_ID"
}

The signed tokens must include these claims in the payload:

{
	// Unique identification of your connection name.

	"externalUserId": "user_id",
    "externalProjectId": "user_project_id"
    "firstName": "John",
    "lastName": "Doe",
    "email": "mo@activepieces.om",
	// Expiry timestamp for token
	"exp": 1856563200
}

You can use any JWT library to generate the token. Here is an example using the jsonwebtoken library in NodeJs:

You can also use this tool to generate a quick example: https://dinochiesa.github.io/jwt/.

NodeJs
const jwt = require('jsonwebtoken');

// JWT NumericDates specified in seconds:
const currentTime = Math.floor(Date.now() / 1000);
let token = jwt.sign(
  {
    externalUserId: "user_id",
    externalProjectId: "user_project_id",
    firstName: "John",
    lastName: "Doe",
    email: "mo@activepieces.om",
    exp: currentTime + (24 * 60 * 60), // 1 day from now
  },
  process.env.ACTIVEPIECES_SIGNING_KEY,
  {
    algorithm: "RS256",
    header: {
      kid: signingKeyID, // Include the "kid" in the header
    },
  }
);

Once you have generated the token, Please check embedding docs to know how to embed the token in the iframe.