Skip to main content

Bearer Token

A Bearer Token connection sends a static token in the Authorization header of every request.

Many official apps use a token: GitHub (Personal access token), Slack (Bot token), Notion (Internal integration secret) and Stripe (Secret key). Connect those from their app page: the base URL, default headers and allowed domains are already set, and the app's actions and triggers work with the connection. See the GitHub walkthrough for an example. For any other API, use the generic template.

Using the generic Bearer Token template​

  1. Go to Apps, open Any REST API on the Generic tab and click Connect → Bearer Token.
  2. Give the connection a name, paste the token (or click Use secret to reference a project secret) and click Create.
  3. Select the connection in an HTTP Request node (Auth → Use Connection).
FieldKeyDefaultDescription
Tokentoken—The token value
Header Prefixheader_prefixBearerThe scheme in front of the token. Change it for APIs that expect another scheme, e.g. Token. Leave it empty to send the raw token

With the defaults, Blokkio sets:

Authorization: Bearer your-token-value
Header PrefixHeader sent
BearerAuthorization: Bearer your-token-value
TokenAuthorization: Token your-token-value
(empty)Authorization: your-token-value

The connection replaces any Authorization header set on the node. The token is not refreshed: when it expires or is revoked, edit the connection (⋯ → Edit or rename on the Connections page) and paste a new one. If the token comes from a secret, update the secret instead.

:::tip Pin the token to the API's domain The Any REST API templates have no allowed domains, so their connections may be used with any host. To pin a token to one API, create a custom app (Apps → Custom app → New custom app, start from Bearer Token), set its Allowed domains, Base URL and a Test request, and connect it. :::

Bearer tokens in custom apps​

If you switch a custom app's Auth strategy to Bearer Token, it gets one parameter, Bearer Token (bearer_token), which is sent as Authorization: Bearer ….

When to use it​

Use Bearer Token for APIs that accept a long-lived token: personal access tokens, static JWTs or API keys sent as Bearer. For short-lived tokens that must be refreshed, use OAuth 2.0. For a header other than Authorization, use API Key.