Skip to main content

Overview

To access content protected by Supertab Connect, your bot needs a license token. This token proves you’ve agreed to the publisher’s licensing terms and authorizes access to their content. The flow:
  1. Fetch the publisher’s license.xml to get their licensing terms
  2. Request a license token from Supertab Connect
  3. Include the token in your request to the publisher’s content

Using the SDK

The Supertab Connect SDK handles token generation for you.

Installation

npm install @getsupertab/supertab-connect-sdk

Generate a License Token

import { SupertabConnect } from "@getsupertab/supertab-connect-sdk";

// Fetch the publisher's license
const licenseResponse = await fetch("https://publisher.com/license.xml");
const licenseXml = await licenseResponse.text();

// Generate a license token
const token = await SupertabConnect.generateLicenseToken(
  "urn:stc:customer:system:your-system-id", // clientId
  "your-key-id", // kid
  process.env.PRIVATE_KEY_PEM, // privateKeyPem
  "https://publisher.com/article/123", // resourceUrl
  licenseXml // licenseXml
);

// Access the content
const response = await fetch("https://publisher.com/article/123", {
  headers: {
    Authorization: `License ${token}`,
  },
});

const content = await response.text();

SDK Reference

generateLicenseToken(
  clientId: string,      // Your System's Client ID
  kid: string,           // Your Key ID
  privateKeyPem: string, // Your private key in PEM format
  resourceUrl: string,   // The URL you want to access
  licenseXml: string     // The publisher's license.xml content
): Promise<string>
Returns: A signed license token (JWT) that you include in your requests.

Using the License Token

Include the token in the Authorization header using the License scheme:
Authorization: License eyJhbGciOiJFUzI1NiIs...
Use License, not Bearer. This is the RSL standard for license token authentication.

Example Request

const response = await fetch("https://publisher.com/article/123", {
  headers: {
    Authorization: `License ${token}`,
  },
});

if (response.ok) {
  const content = await response.text();
  // Process content
} else if (response.status === 402) {
  // Payment required - check license terms
} else if (response.status === 401) {
  // Invalid or expired token
}

Discovering Licensed Sites

To find a site’s license, check their robots.txt for a License directive:
User-agent: *
License: https://publisher.com/license.xml
If present, fetch the license URL to see their terms before accessing content.