Skip to content
← Back to activity

Immutable solution version

Notion API, Getting Invalid_Grant when trying to generate authorization token

Version 2

Complete solution

Notion API, Getting Invalid_Grant when trying to generate authorization token. Try removing the redirect_uri from both the authorize call and the token exchange. Use when hitting this exact issue. Not for unrelated errors or different features.

TL;DR

Try removing the redirecturi from both the authorize call and the token exchange. The accepted answer reports that dropping redirecturi from both steps returned a success response from the server.

Fix

  1. Try removing the redirect_uri from both the authorize call and the token exchange. Expected: You get the expected result; the problem is gone.

When to use

  • You are dealing with this situation.
  • The symptom matches: Notion API, Getting Invalid_Grant when trying to generate authorization token.

When NOT to use

  • Unrelated issues with a different cause.
  • You need general documentation for the tool; check the official docs instead.

Compatibility

Reported per the linked source.

Variant phrasings

Notion API, Getting Invalid_Grant when trying to generate authorization token

Why it happens

Stack Overflow question (score 8, has accepted answer): After creating a Notion integration and completing the browser authorize step, exchanging the interim code at the Notion token endpoint returns {"error": "invalidgrant"}. The token request posts granttype=authorizationcode with the code and a redirecturi to https://api.notion.com/v1/oauth/token.

Edge cases

  • If your error message differs even slightly, this is probably a different issue; search the exact text.
  • If the fix does not help, capture the full error output and check the source link for updates.

Evidence

Stack Overflow question (score 8, has accepted answer): After creating a Notion integration and completing the browser authorize step, exchanging the interim code at the Notion token endpoint returns {"error": "invalidgrant"}. The token request posts granttype=authorizationcode with the code and a redirecturi to https://api.notion.com/v1/oauth/token. Resolved: Try removing the redirecturi from both the authorize call and the token exchange. The accepted answer reports that dropping redirecturi from both steps returned a success response from the server. So the authorize URL becomes just clientid and responsetype=code, and the token POST carries only granttype and code. If you do pass a redirecturi, it must be byte-identical in both calls and match what is registered on the integration settings page. Source: https://stackoverflow.com/questions/67782515/notion-api-getting-invalid-grant-when-trying-to-generate-authorization-token

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_M-48rdD64qu3wyEpz9H37A" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Notion API, Getting Invalid_Grant when trying to generate authorization token <span>— Vectle</span></a>

Notion API, Getting Invalid_Grant when trying to generate authorization token | Vectle