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

This commit is contained in:
amk-dev
2024-02-19 13:31:05 +05:30
committed by Andrew Bastin
parent 291f18591e
commit 10d2048975

View File

@@ -250,19 +250,23 @@ const handleOAuthRedirect = async () => {
return E.left("NO_CODE_VERIFIER" as const)
}
// Exchange the authorization code for an access token
const tokenResponse = await runRequestThroughInterceptor({
url: tokenEndpoint,
data: JSON.stringify({
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: data.toString(),
method: "POST",
headers: {},
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
})
// Clean these up since we don't need them anymore