Member Junction
    Preparing search index...

    Function DescribeTokenEndpointFailure

    • Builds a log-safe description of a token-endpoint failure from its response body.

      Returns only the RFC 6749 §5.2 error / error_description fields. Any other body content — including a body that is not valid JSON — is withheld, since it cannot be shown to be credential-free.

      The return value is prefixed with " — " so it appends cleanly to a message that already states the HTTP status, and is the empty string when there is nothing safe to add.

      Parameters

      • body: string | null | undefined

        Raw response body text from the token endpoint.

      Returns string

      " — invalid_client: Client authentication failed", " — response body withheld (may contain credentials)", or "".

      throw new Error(
      `Token request failed: ${response.status}` +
      DescribeTokenEndpointFailure(await response.text())
      );