Solution skill
Linear OAuth: token endpoint returns 503, then 400 invalid_grant on every retry
Complete solution
Shows how to fix linear OAuth: token endpoint returns 503, then 400 invalid_grant on every retry. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
For "invalidgrant": linear's server choked while persisting the token for that scope, but by then the authorization code had already been consumed, so every retry returned invalid\grant because the code was spent.
invalid_grantSteps
- You are not rate-limited, and your code was valid. The culprit was the
timeSchedule:writescope in the authorize URL. Linear's server choked while persisting the token for that scope, but by then the authorization code had already been consumed, so every retry returnedinvalid_grantbecause the code was spent. That is why you see the weird 503-then-400 pattern: the first request fails after consuming the code, and all subsequent requests fail because the code is gone. The fix is to droptimeSchedule:writefrom your scope list (it overlaps with the other scopes you already request anyway) and start a fresh OAuth flow. Linear also fixed this server-side, and the reporter confirmed the token exchange worked after the change.
When to use
You are seeing this: I am building Linear OAuth and the token endpoint is behaving strangely. Use this skill when you run into "Linear OAuth: token endpoint returns 503, then 400 invalid_grant on every retry".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Sources
- https://api.linear.app/oauth/token`
Evidence
Question: I am building Linear OAuth and the token endpoint is behaving strangely. The first POST to https://api.linear.app/oauth/token with grant_type=authorization_code returns 503 Service Unavailable. Every request after that returns 400 Bad Request with {"error": "invalid_grant", "error_description": "Invalid grant: authorization code is invalid"}. My clientid, clientsecret, redirect_uri, and code are all correct. Am I rate-limited, or is something else going on?
Verified resolution: You are not rate-limited, and your code was valid. The culprit was the timeSchedule:write scope in the authorize URL. Linear's server choked while persisting the token for that scope, but by then the authorization code had already been consumed, so every retry returned invalid_grant because the code was spent. That is why you see the weird 503-then-400 pattern: the first request fails after consuming the code, and all subsequent requests fail because the code is gone. The fix is to drop timeSchedule:write from your scope list (it overlaps with the other scopes you already request anyway) and start a fresh OAuth flow. Linear also fixed this server-side, and the reporter confirmed the token exchange worked after the change.
Source: https://github.com/linear/linear/issues/637
Thread: https://vectle.com/threads/thr_HHLrdlOP9mX7EEiUNHbKCw
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_dOXZmycctEOZy0QyskPIJg" 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">Linear OAuth: token endpoint returns 503, then 400 invalid_grant on every retry <span>— Vectle</span></a>