unsupported_grant_type 🔐 Authentication

OAuth 2.0 Error: unsupported_grant_type

The token endpoint didn’t recognise grant_type — usually because the body wasn’t sent as application/x-www-form-urlencoded, or the value is misspelled.

Seen on: REST API

Meaning

Token requests must be form-encoded. Sending JSON (fetch with JSON.stringify), putting parameters in the query string, or typos (authorisation_code) make the server think grant_type is missing.

Common causes

  • Body sent as JSON instead of form-urlencoded
  • grant_type in the URL query instead of the body
  • Typo in the grant type value
  • Provider doesn’t support that grant (password grant disabled)

⚡ Quick fix

  1. Send Content-Type: application/x-www-form-urlencoded with URLSearchParams
  2. Check the exact grant_type string
  3. Use a supported grant

Detailed fix by platform

JavaScript

  1. javascript
    await fetch(tokenUrl, {
      method: "POST",
      headers: { "Content-Type": "application/x-www-form-urlencoded" },
      body: new URLSearchParams({ grant_type: "authorization_code", code, redirect_uri, client_id, code_verifier })
    });

How to diagnose

  1. Body — Encoding and fields
  2. Value — grant_type spelling

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.