Errors
401 - malformed bearer token
What happened
The Authorization header arrived but does not have the expected Bearer token format. Missing prefixes, pasted punctuation or newlines can cause this.
- Inspect header constructionCheck the format without printing its secret value.
- Remove extra charactersAvoid quotes, newlines or a missing Bearer prefix.
- 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
- Use the literal prefix Bearer followed by one space and the token.
- Check that the secret variable is populated without printing its value.
- Remove accidental surrounding quotes or newlines.
- 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
Bearerprefix. - Lowercase
bearerfrom 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.