OriginChainDB
Errors

401 - malformed bearer token

← Errors examples

What happened

The Authorization header arrived but does not have the expected Bearer token format. Missing prefixes, pasted punctuation or newlines can cause this.

Repair the Authorization header formatThe required prefix is Bearer followed by one space and the loaded token.
  1. Inspect header constructionCheck the format without printing its secret value.
  2. Remove extra charactersAvoid quotes, newlines or a missing Bearer prefix.
  3. Verify the corrected headerSend the request with a properly loaded credential.

Request that triggers it

An Authorization header that's missing the Bearer prefix.

curl -X POST "https://$OC_HOST/v1/tenants/$OC_TENANT/sql" \
  -H "Authorization: not-a-real-bearer" \
  -H "Content-Type: application/json" \
  -d '{"sql": "SELECT id FROM shop.products LIMIT 1"}'

Read the response

{
  "error": "unauthorized",
  "message": "Authorization header must be 'Bearer <token>'",
  "retry": false
}

Fix the request

  1. Use the literal prefix Bearer followed by one space and the token.
  2. Check that the secret variable is populated without printing its value.
  3. Remove accidental surrounding quotes or newlines.
  4. Send the corrected header.

Keep in mind: The response marks this request as non-retryable until the header is corrected.

Common causes

  • Token sent without the Bearer prefix.
  • Lowercase bearer from a snippet - the parser is case-sensitive on the scheme name.
  • Smart-quote characters from a doc copy-paste (" vs ").
  • Trailing whitespace or newline pulled in from a file read.
  • Two tokens concatenated by accident (env var set twice).

Continue

See error handling and retries, or return to error examples.

© 2026 Silicoyn Technologies Pvt Ltd

On this page