bad_verification_code Authentication Origin: Application & API Last updated 13 Oct 2026

GitHub OAuth: {"error":"bad_verification_code","error_description":"The code passed is incorrect or expired."}

The authorization code sent to GitHub’s token endpoint was already used, expired (10 minutes), or belongs to another OAuth app.

Exact message you may see The code passed is incorrect or expired
Seen on: REST API

Meaning

Codes are single-use. Double requests (React StrictMode, retries, page refresh on callback) consume the code, and the second exchange fails. Mixing client IDs between environments also fails.

Common causes

  • Code exchanged twice (StrictMode double effect, retries, refresh)
  • Code older than 10 minutes
  • client_id/secret from another OAuth app
  • redirect_uri differs from the authorize request

⚡ Quick fix

  1. Exchange the code once on the server and redirect away from the callback URL
  2. Guard against duplicate exchange
  3. Use matching client credentials per environment

Detailed fix by platform

JavaScript

  1. javascript
    // Next.js route handler — exchange once, then redirect
    const r = await fetch("https://github.com/login/oauth/access_token", { method: "POST", headers: { Accept: "application/json" }, body: new URLSearchParams({ client_id, client_secret, code }) });

How to diagnose

  1. Requests — How many exchanges per code?
  2. Age — Time since redirect
  3. App — Client ID matches?

🔧 Still not fixed?

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

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

AADSTS500113 — AADSTS500113: No reply address is registered for the application (Azure)AADSTS500113Access blocked: has not completed the Google verification process — Google OAuth: Error 403: access_denied — The developer hasn't given you access to this app / has not completed the Google verification process (Authentication)Access blocked: has n…access_denied — OAuth 2.0 Error: access_denied (The user or authorization server denied the request) (Authentication)access_deniedauth/popup-closed-by-user — Firebase Auth: auth/popup-closed-by-user / auth/popup-blocked / auth/cancelled-popup-request (Authentication)auth/popup-closed-by-…auth/unauthorized-domain — Firebase Auth: auth/unauthorized-domain — This domain is not authorized for OAuth operations for your Firebase project (Authentication)auth/unauthorized-dom…deleted_client — Google OAuth: Error 401: deleted_client — The OAuth client was deleted (Authentication)deleted_clientdisallowed_useragent — Google OAuth: Error 403: disallowed_useragent (sign-in from an embedded WebView) (Authentication)disallowed_useragentGoogle hasn't verified this app — Google OAuth: Google hasn't verified this app / This app isn't verified (Authentication)Google hasn't verifie…bad_verif…

Explore the map of this error Full error map →

🧠 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.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.