Token Types

Understanding the different authentication tokens in Data Border

Token Types

Data Border uses multiple token types for different purposes. Understanding each type helps you implement proper token management.

Token Overview

Loading diagram...

Data Border Tenant Refresh Token

The root credential for your WMS tenant.

PropertyValue
FormatRandom string (e.g., rt_abc123...)
ExpiryNever expires
StoragePlain text in Data Border database
PurposeExchange for Data Border access tokens

Obtaining

Returned when creating a tenant:

{
  "success": true,
  "data": {
    "tenant_id": "clx1y2z3...",
    "refresh_token": "rt_abc123..."
  }
}

Usage

Exchange for a Data Border access token:

POST /api/get-adb-access-token
{
  "tenant_id": "clx1y2z3...",
  "refresh_token": "rt_abc123..."
}

Security

  • Store encrypted at rest in your WMS
  • Never expose to clients - server-side only
  • Cannot be rotated without creating a new tenant
  • One per tenant - shared across all operations

Data Border Access Token

Short-lived JWT for tenant-level operations.

PropertyValue
FormatJWT (HS256 signed)
Expiry30 days
StorageMemory/cache
PurposeSeller management operations

Token Claims

{
  "tenant_id": "clx1y2z3...",
  "iat": 1640995200,
  "exp": 1643587200
}

Usage

Use in x-adb-access-token header:

POST /api/claim-code
x-adb-access-token: eyJhbGciOiJIUzI1NiIs...

Refresh Strategy

// Refresh 7 days before expiry
const REFRESH_BUFFER = 7 * 24 * 60 * 60 * 1000

function shouldRefreshAdbToken(token) {
  const decoded = decodeJwt(token)
  const expiresAt = decoded.exp * 1000
  return Date.now() > expiresAt - REFRESH_BUFFER
}

Data Border Seller Refresh Token

Credential for a connected Amazon seller.

PropertyValue
FormatRandom string (e.g., srt_def456...)
ExpiryNever expires
StoragePlain text in Data Border database
PurposeExchange for seller access tokens

Obtaining

Returned when claiming OAuth authorization:

{
  "success": true,
  "data": {
    "refresh_token": "srt_def456..."
  }
}

Usage

Exchange for a seller access token:

POST /api/get-seller-access-token
x-adb-access-token: <ADB_TOKEN>
{
  "seller_id": "seller_abc123",
  "refresh_token": "srt_def456..."
}

Security

  • Store encrypted per-seller in your WMS
  • Pair with amazonTokenSecret - both needed for operations
  • Cannot be rotated without re-OAuth
  • One per seller per tenant

Seller Access Token

Short-lived JWT for seller operations.

PropertyValue
FormatJWT (HS256 signed)
Expiry24 hours
StorageMemory/cache
PurposeAll seller API operations

Token Claims

{
  "tenant_id": "clx1y2z3...",
  "seller_id": "seller_abc123",
  "iat": 1640995200,
  "exp": 1641081600
}

Usage

Use in x-seller-access-token header (with x-amazon-token-secret):

GET /api/pii/getPII/123-456
x-seller-access-token: eyJhbGciOiJIUzI1NiIs...
x-amazon-token-secret: BASE64_SECRET

Refresh Strategy

// Refresh 1 hour before expiry
const REFRESH_BUFFER = 60 * 60 * 1000

function shouldRefreshSellerToken(token) {
  const decoded = decodeJwt(token)
  const expiresAt = decoded.exp * 1000
  return Date.now() > expiresAt - REFRESH_BUFFER
}

Amazon Refresh Token

Amazon's long-lived credential for SP-API access.

PropertyValue
FormatAmazon token string (e.g., Atzr|IwEB...)
ExpiryNever expires (until revoked)
StorageAES-256-GCM encrypted in Data Border database
PurposeExchange for Amazon access tokens

Encryption

Encrypted with the seller's amazonTokenSecret:

Plaintext: Atzr|IwEBIG...
Encrypted: BASE64(salt + iv + tag + ciphertext)

Security

  • Never stored in plaintext - always encrypted
  • Decryption requires amazonTokenSecret - which Data Border doesn't store
  • Isolated per seller - unique encryption key each
  • Revokable by Amazon or seller

Amazon Access Token

Short-lived token for SP-API requests.

PropertyValue
FormatAmazon token string
Expiry~1 hour
StorageIn-memory only
PurposeAuthenticate to Amazon SP-API

Lifecycle

Data Border automatically manages Amazon access tokens:

Loading diagram...

Caching

Data Border caches Amazon access tokens until near expiry to minimize LWA calls.


Restricted Data Token (RDT)

Single-use token for accessing PII via SP-API.

PropertyValue
FormatAmazon RDT string
ExpirySingle use / ~1 hour
StorageIn-memory only
PurposeAccess restricted SP-API data (PII)

Automatic Generation

Data Border automatically generates RDTs when accessing endpoints that require them:

Loading diagram...

RDT Scope

Each RDT is scoped to specific data elements:

  • buyerInfo - Buyer name, email
  • shippingAddress - Shipping address details
  • restrictedReportDocument - Report content

Amazon Token Secret

Not a token, but the encryption key for Amazon tokens.

PropertyValue
FormatBase64-encoded random data
Length32-64 characters
StorageYour WMS only - never stored in Data Border
PurposeEncrypt/decrypt Amazon refresh token

Critical Properties

The amazonTokenSecret is not stored in Data Border. You must store and provide it with every request that needs Amazon access.

  • Generated during OAuth initialization
  • Sent in x-amazon-token-secret header
  • Required for any operation accessing Amazon data
  • If lost, seller must re-authorize

Token Comparison Table

TokenValidityStorageEncryptedRequired For
Tenant RefreshForeverData Border DBNoGetting Data Border access tokens
Data Border Access30 daysMemoryNo (JWT)Seller management
Seller RefreshForeverData Border DBNoGetting seller access tokens
Seller Access24 hoursMemoryNo (JWT)All seller operations
Amazon RefreshForeverData Border DBYesGetting Amazon access
Amazon Access~1 hourMemoryNoSP-API calls
RDTSingle useMemoryNoPII access
Token SecretN/AYour WMSN/ADecrypting Amazon tokens

Token Management Best Practices

Storage Recommendations

// Your WMS database schema
const sellerCredentials = {
  // From Data Border
  adbSellerId: 'seller_abc123',
  sellerRefreshToken: encrypt('srt_def456...'),  // Encrypt at rest
  
  // Your secret
  amazonTokenSecret: encrypt('BASE64_SECRET'),   // Never send to Data Border for storage
  
  // Cached tokens (optional, can regenerate)
  cachedAccessToken: 'eyJ...',
  accessTokenExpiry: new Date()
}

Refresh Patterns

class TokenManager {
  constructor() {
    this.tokens = new Map()
  }

  async getSellerToken(sellerId) {
    const cached = this.tokens.get(sellerId)
    
    // Refresh 1 hour before expiry
    if (cached && cached.expiry > Date.now() + 3600000) {
      return cached.token
    }

    const newToken = await this.refreshSellerToken(sellerId)
    this.tokens.set(sellerId, {
      token: newToken,
      expiry: Date.now() + 24 * 3600000  // 24 hours
    })
    
    return newToken
  }
}

Next Steps

Encryption

How tokens are encrypted at rest.

WAF & Rate Limiting

Request protection mechanisms.