token_malformed: The browser token is not in the minted form

The token in the URL or the Authorization header is not in the shape of a Dynamo browser token: it was cut short or changed, or it is some other value (an API key, for example). On the multi-tenant hosted tier the same code also answers a token minted for another kind of surface, which a single-tenant deployment answers with token_wrong_kind. A token in the right shape whose signature does not verify answers token_signature_invalid on a single-tenant deployment.

What to do

On the wire

HTTP 401, error type authentication_error. The widget routes always answer JSON; the budget link, portal and top-up pages answer a short HTML page naming the code, or JSON to a client that sends Accept: application/json (and not text/html). The body depends on who answers.

A single-tenant (self-hosted) core answers:

{
  "error": "unauthorized",
  "errorDetail": {
    "type": "authentication_error",
    "code": "token_malformed",
    "message": "the token is not a Dynamo browser token",
    "param": null,
    "doc_url": "…/developers/widgets.md#token-malformed",
    "fix": "use the token exactly as minted"
  }
}

The top-up page points doc_url at the top-up guide instead.

The multi-tenant hosted front door checks the token's shape and kind before the request reaches the account's core, and answers:

{
  "error": "token_malformed",
  "errorDetail": {
    "type": "authentication_error",
    "code": "token_malformed",
    "message": "the token is not a Dynamo browser token for this surface",
    "param": null,
    "doc_url": "…/errors/token_malformed.md",
    "fix": "open the link the service gave you, or ask it for a new one"
  }
}

See all error codes.