Trying to get OAuth2 tokens for Google Auth just fails

I'm currently trying to implement OAuth callback, but when trying to fetch tokens like so:
const body = new URLSearchParams({
code,
client_id: this.clientId,
client_secret: this.clientSecret,
redirect_uri: this.redirectUrl,
grant_type: "authorization_code",
});



const res = await fetch("https://oauth2.googleapis.com/token", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body,
});
const body = new URLSearchParams({
code,
client_id: this.clientId,
client_secret: this.clientSecret,
redirect_uri: this.redirectUrl,
grant_type: "authorization_code",
});



const res = await fetch("https://oauth2.googleapis.com/token", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body,
});
quite literally, nothing happens... it just says (pending). This only occurs when deployed, not in the local environment, not in the remote preview.
No description
1 Reply
nitLix
nitLixOP5mo ago
I've investigated further and it SPECIFICALLY seems like it only doesnt work with google. Identical code trying to get tokens from discord does not fail. might google's APIs be blocking cloudflare IPs?

Did you find this page helpful?