Open timootten opened 1 week ago
Hey, there is an error when using this:
const tokens = await amazonCognito.validateAuthorizationCode(code, codeVerifier);
Error:
OAuth2RequestError: invalid_client
The problem: aws doesn't support http basic auth.
Solution:
try { const urlParams = { grant_type: "authorization_code", code, redirect_uri: "http://localhost:3000/api/auth/callback/cognito", code_verifier: codeVerifier, } const URL = `${(process.env.AUTH_COGNITO_URL ?? "")}/oauth2/token?${new URLSearchParams(Object.entries(urlParams)).toString()}`; const body = { client_id: process.env.AUTH_COGNITO_ID ?? "", client_secret: process.env.AUTH_COGNITO_SECRET ?? "" } const response = await fetch(URL, { method: "POST", headers: { 'Content-Type': "application/x-www-form-urlencoded", }, body: new URLSearchParams(Object.entries(body)).toString() }) const json = await response.json(); console.log("json", json) } catch(error) { ... }
Hey, there is an error when using this:
Error:
The problem: aws doesn't support http basic auth.
Solution: