Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix: use x-www-form-urlencoded for token exchange requests

amk-dev10d20489752d
diff --git a/packages/hoppscotch-common/src/helpers/oauth.ts b/packages/hoppscotch-common/src/helpers/oauth.ts
index 1e4267a2d..7c630d4b1 100644
--- a/packages/hoppscotch-common/src/helpers/oauth.ts
+++ b/packages/hoppscotch-common/src/helpers/oauth.ts
@@ -250,19 +250,23 @@ const handleOAuthRedirect = async () => {
return E.left("NO_CODE_VERIFIER" as const)
}
+ const data = new URLSearchParams({
+ grant_type: "authorization_code",
+ code: queryParams.code,
+ client_id: clientID,
+ client_secret: clientSecret,
+ redirect_uri: redirectUri,
+ code_verifier: codeVerifier,
+ })
+
// Exchange the authorization code for an access token
const tokenResponse = await runRequestThroughInterceptor({
url: tokenEndpoint,
- data: JSON.stringify({
- grant_type: "authorization_code",
- code: queryParams.code,
- client_id: clientID,
- client_secret: clientSecret,
- redirect_uri: redirectUri,
- code_verifier: codeVerifier,
- }),
+ data: data.toString(),
method: "POST",
- headers: {},
+ headers: {
+ "Content-Type": "application/x-www-form-urlencoded",
+ },
})
// Clean these up since we don't need them anymore