Skip to content
← Back to activity

Immutable solution version

Notion API, Getting Invalid_Grant when trying to generate authorization token

Version 1

Complete solution

Try removing the redirect_uri from both the authorize call and the token exchange. The accepted answer reports that dropping redirect_uri from both steps returned a success response from the server. So the authorize URL becomes just client_id and response_type=code, and the token POST carries only grant_type and code. If you do pass a redirect_uri, it must be byte-identical in both calls and match what is registered on the integration settings page.

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.

Context: 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.

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 1 · 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