I'm using google-auth-library
in nodejs
Everything was working fine. until for some reason my one of the domain is down. api.example1.com
and in google console the redirect uri was ->
https://api.example1.com/google/cb
there was nothing special in that route since I'm already getting the
auth_code
from client like -> React, Android
import { useGoogleLogin } from "@react-oauth/google";
so I've just created another server with same code on the api.example2.com
and I've also added this in the authorized redirect urls.
but unfortunately. it giving error even though
CLIENT_ID
and CLIENT_SECRET
are correct.
This is Error I Got
{
"error": "invalid_client",
"error_description": "Unauthorized"
}
const oAuth2Client = new OAuth2Client({
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_SECRET_ID,
redirectUri: process.env.REDIRECT_URI,
});
Usage
const { tokens } = await oAuth2Client.getToken(code);
Over Confidence is not a good thing.
You may think that every credential is valid but that is not the case.
In my case my CLIENT_SECRET
was different.
so double check if possible triple check every credential for this error.
invalid_client
{
"error": "invalid_client",
"error_description": "Unauthorized"
}