brandTemplate.verifyToken

API reference for the brandTemplate.verifyToken method.

This API is a preview. Preview APIs are unstable and may change without warning. You can't release public apps using this API until it's stable.

Usage: Extract brand template token from query parameter:

import { brandTemplate, tokenExtractors } from '@canva/app-middleware/express';
app.get('/api/template/data', brandTemplate.verifyToken({
appId: 'your-app-id',
tokenExtractor: tokenExtractors.fromQuery('brand_template_token')
}), handler);
TYPESCRIPT

Parameters

optionsBrandTemplateAuthOptions
Required

Configuration options

appIdstring
Required

The ID of the Canva app, obtained via the developer portal canva.com/developers.

tokenExtractorTokenExtractor
Required

A function that extracts the brand template JWT token from the request. Unlike user tokens, brand template tokens have no default extractor and must be explicitly configured based on how your app passes the brand template token.

Example

tokenExtractor: tokenExtractors.fromBearerAuth()
tokenExtractor: tokenExtractors.fromQuery('brand_template_token')
tokenExtractor: tokenExtractors.fromHeader('X-Brand-Template-Token')
TYPESCRIPT

Parameters

reqRequest
Required

Returns

cacheMaxAgeMinutesnumber
Optional

The maximum age of the JWKS cache in minutes.

Default value: 60

timeoutMsnumber
Optional

The timeout for the JWKS fetch in milliseconds.

Default value: 30000

baseUrlstring
Optional

The base URL for the JWKS endpoint.

Default value: "https://api.canva.com"

Returns

Express middleware that verifies brand template JWT tokens.

RequestHandler