{"record":{"id":"753d72c6d4b53d40","repo":"Kong/insomnia","slug":"oauth-2-0-error-code-msg-uri","errorCode":null,"errorMessage":"OAuth 2.0 Error ${code}\n\n${msg}\n\n${uri}","messagePattern":"OAuth 2\\.0 Error (.+?)\n\n(.+?)\n\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/insomnia/src/main/network/o-auth-2/get-token.ts","lineNumber":333,"sourceCode":"          });\n        } catch (err) {\n          timeline.push(logEntry(`Authorization window error: ${err.message}`));\n          throw err;\n        }\n      }\n\n      console.log('[oauth2] Detected redirect ' + redirectedTo);\n      timeline.push(\n        logEntry(`Authorization redirect detected: ${redirectedTo}`),\n        logEntry('Exchanging code for token'),\n      );\n      const redirectParams = Object.fromEntries(new URL(redirectedTo).searchParams);\n      if (redirectParams.error) {\n        const code = redirectParams.error;\n        const msg = redirectParams.error_description;\n        const uri = redirectParams.error_uri;\n        timeline.push(logEntry(`Authorization error: ${code} - ${msg || 'no description'}`));\n        throw new Error(`OAuth 2.0 Error ${code}\\n\\n${msg}\\n\\n${uri}`);\n      }\n      console.log('[oauth2] Detected code ' + redirectParams.code);\n      params = [\n        { name: 'grant_type', value: GRANT_TYPE_AUTHORIZATION_CODE },\n        { name: 'code', value: redirectParams.code },\n        ...insertAuthKeyIf('redirect_uri', redirectUrl),\n        ...insertAuthKeyIf('audience', authentication.audience),\n        ...insertAuthKeyIf('resource', authentication.resource),\n        ...insertAuthKeyIf('code_verifier', codeVerifier),\n      ];\n    } else if (authentication.grantType === 'password') {\n      params = [\n        { name: 'grant_type', value: 'password' },\n        ...insertAuthKeyIf('username', authentication.username),\n        ...insertAuthKeyIf('password', authentication.password),\n        ...insertAuthKeyIf('scope', authentication.scope),\n        ...insertAuthKeyIf('audience', authentication.audience),\n      ];","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/Kong/insomnia/blob/d9bb2b0142600f21309832daea3317942d285984/packages/insomnia/src/main/network/o-auth-2/get-token.ts#L315-L351","documentation":"Formatted OAuth 2.0 provider error raised in getOAuth2Token: the authorization redirect back from the provider carried an error query parameter (with optional error_description and error_uri), so the code-for-token exchange is aborted.","triggerScenarios":"Thrown at packages/insomnia/src/main/network/o-auth-2/get-token.ts:333 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read error_description/error_uri for the provider-specific cause (bad client_id, denied consent, mismatched redirect URI)","Fix the OAuth app configuration on the provider and retry the flow","If consent was denied, re-authorize and approve the requested scopes"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d9bb2b0142600f21309832daea3317942d285984","analyzedAt":"2026-08-26T18:04:05.187Z","contentChangedAt":"2026-08-26T18:04:05.187Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}