Authentication overview

License-API provides a RESTful interface for managing software licenses, product activations, and usage tracking. To ensure that all interactions with the API are authorized and secure, License-API requires authentication for nearly all endpoints. The primary methods supported are API Keys and JSON Web Tokens (JWTs), each suited for different integration patterns and security requirements. Understanding these methods is crucial for securely integrating License-API into your applications.

Authentication protects your licensing data and prevents unauthorized access to your license management operations. All API requests must be made over HTTPS to ensure data encryption in transit, irrespective of the authentication method used. For detailed information on specific endpoints and their authentication requirements, refer to the official License-API API Reference.

Supported authentication methods

License-API supports two primary authentication methods, each designed for specific use cases:

  1. API Keys: These are long-lived, secret tokens used to authenticate requests. They are generally suitable for server-side applications where the key can be stored securely and not exposed to end-users. API Keys provide direct access to the API and should be treated as sensitive credentials.
  2. JSON Web Tokens (JWTs): JWTs are a more flexible, open standard for creating tokens that assert a set of claims. Unlike API keys, JWTs are typically short-lived and can carry additional information (claims) about the authenticated user or context. They are often used in scenarios where client-side applications need to authenticate without exposing a permanent secret, or when granular, time-bound access is required. License-API allows you to generate JWTs from your API keys for specific use cases, such as authenticating client-side applications or mobile apps for license validation. The structure and security of JSON Web Tokens are defined by RFC 7519.

The following table summarizes the key characteristics of each authentication method:

Method When to Use Security Level Key Management
API Key Server-to-server communication, backend services, secure environments. High (if kept secret) Generated in License-API dashboard, manually managed.
JSON Web Token (JWT) Client-side applications (web/mobile), time-bound access, granular permissions, distributed systems. High (if signed securely and validated) Generated server-side using an API Key, then passed to client.

Getting your credentials

To begin authenticating with License-API, you will need to obtain your API Key. Follow these steps:

  1. Sign Up/Log In: Navigate to the License-API website and either sign up for a new account or log in to your existing one. A free Developer Plan is available, offering up to 100 licenses and 1000 requests per month.
  2. Access Dashboard: Once logged in, access your License-API developer dashboard.
  3. Navigate to API Keys: Look for a section or tab typically labeled "API Keys," "Settings," or "Developers."
  4. Generate Key: If you don't have an existing key, you will be prompted to generate one. Give your key a descriptive name to help you identify its purpose later.
  5. Copy Key: Once generated, your API Key will be displayed. It is critical to copy this key immediately and store it securely, as it may only be shown once for security reasons. If you lose it, you may need to revoke it and generate a new one.

For JWTs: JWTs are not generated directly in the dashboard. Instead, you use your API Key to programmatically generate JWTs from your backend server. The License-API documentation provides specific endpoints and SDK methods for generating JWTs securely, which are then passed to your client-side applications.

Authenticated request example

All authenticated requests to License-API must include your API Key in the Authorization header using the Bearer scheme, or as a query parameter for specific endpoints. For JWTs, the process is similar, with the JWT replacing the API Key in the Authorization header.

Using an API Key (Python example)

This example demonstrates how to make an authenticated request to retrieve a list of licenses using a Python SDK provided by License-API. The example assumes you have the Python SDK installed and your API key stored securely.

import licenseapi

# Replace with your actual API Key
api_key = "YOUR_LICENSE_API_KEY"

# Configure the SDK with your API Key
licenseapi.api_key = api_key

try:
    # Make an authenticated request to list licenses
    licenses = licenseapi.License.list()
    for license in licenses:
        print(f"License ID: {license.id}, Product: {license.product_id}, Status: {license.status}")
except licenseapi.error.APIError as e:
    print(f"API Error: {e}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

For Node.js:

const licenseapi = require('licenseapi');

// Replace with your actual API Key
const apiKey = 'YOUR_LICENSE_API_KEY';

// Configure the SDK with your API Key
licenseapi.setApiKey(apiKey);

async function listLicenses() {
  try {
    const licenses = await licenseapi.License.list();
    licenses.forEach(license => {
      console.log(`License ID: ${license.id}, Product: ${license.product_id}, Status: ${license.status}`);
    });
  } catch (error) {
    console.error('API Error:', error);
  }
}

listLicenses();

Using a JSON Web Token (JWT) (cURL example)

After generating a JWT from your backend, you would use it in client-side requests as follows:

curl -X GET \n  https://api.license-api.com/v1/licenses/validate \n  -H "Authorization: Bearer YOUR_GENERATED_JWT" \n  -H "Content-Type: application/json"

Remember to replace YOUR_LICENSE_API_KEY and YOUR_GENERATED_JWT with your actual credentials. For more examples across different programming languages, consult the License-API developer documentation.

Security best practices

Adhering to security best practices is essential when integrating any API, especially one handling sensitive licensing information. Follow these guidelines to secure your License-API integration:

  • Keep API Keys Secret: Treat your API Keys like passwords. Never hardcode them directly into client-side code (e.g., JavaScript in a browser, mobile app binaries) or expose them in public repositories. Store them in environment variables, secret management services, or encrypted configuration files on your server.
  • Use HTTPS for All Requests: Always ensure that all communication with the License-API occurs over HTTPS. This encrypts data in transit, protecting your API Keys and sensitive information from eavesdropping. All official License-API endpoints enforce HTTPS.
  • Rotate API Keys Regularly: Periodically rotate your API Keys. If a key is compromised, you can revoke the old key and issue a new one, limiting the window of exposure. The Cloudflare API Token Management guide provides general advice on key rotation strategies.
  • Principle of Least Privilege: If License-API provides granular permissions for API Keys (e.g., read-only, specific resource access), configure your keys with only the minimum necessary permissions required for the task. This limits the damage if a key is compromised.
  • Validate JWTs: If you are using JWTs, always validate them on your backend server before trusting the claims within. This includes verifying the signature, expiration time, and issuer.
  • Securely Generate and Handle JWTs: Generate JWTs on your secure backend server using your API Key, not directly in client-side code. Transmit JWTs to clients over HTTPS and instruct clients to store them securely (e.g., in HTTP-only cookies or secure local storage) and send them in the Authorization header.
  • Monitor API Usage: Regularly monitor your API usage logs for any unusual activity or spikes that might indicate unauthorized access or abuse.
  • Error Handling: Implement robust error handling to gracefully manage authentication failures. Avoid returning verbose error messages that could reveal sensitive information about your system.
  • Stay Updated: Keep your License-API SDKs and any related libraries updated to benefit from the latest security patches and features.