googleapis / googleapis/google-api-nodejs-client
FetchError: Failed to retrieve verification certificates: request to https://www.googleapis.com/oauth2/v1/certs failed, reason: connect ETIMEDOUT
- Lingua principale
- TypeScript
- Stelle
- 12.2k
- Fork
- 2k
- Merge medio
- 1g 9h
- PR unite (30g)
- 24
Descrizione
Hi,
I have an issue, which reoccurs since a week or so in my node js backend.
Back then, when the issue occurred the first time, I created a SO question: [https://stackoverflow.com/questions/71460283/node-js-react-native-failed-to-retrieve-verification-certificates-google-auth-li](https://stackoverflow.com/questions/71460283/node-js-react-native-failed-to-retrieve-verification-certificates-google-auth-li)
The issue now is the same.
What you're trying to do:
I have a middleware where I am checking, if the user is allowed to use the backend routes.
In this middleware (code below) I am checking if the refresh token, stored in the front-end of my react native app in a secure storage. With the refresh token I am retrieving a new access token in order to retrieve the userId and if the user is verified. If so I call the next() method and the user is allowed to use the routes.
My code:
`
console.log('with refresh token a new access token is retrieved, in order to check if email_verified');
const OAuth2 = google.auth.OAuth2;
const oauth2Client = new OAuth2(
config.CLIENT_ID_GOOGLE, // ClientID
config.CLIENT_SECRET_GOOGLE, // Client Secret
"https://www.sagly.at" // Redirect URL
);
oauth2Client.setCredentials({
refresh_token: token,
});
const res = new Promise((resolve, reject) => {
oauth2Client.getAccessToken((err, token, res) => {
if (err) {
} else {
resolve(res);
}
});
});
const idToken = await res;
const client = new OAuth2Client(config.CLIENT_ID_GOOGLE);
result = await client.verifyIdToken({
idToken: idToken.data.id_token,
audience: config.CLIENT_ID_GOOGLE,
});
payload = result.getPayload();
req.userId = payload['sub'];
if (payload && payload.email_verified) {
console.log('next called');
return 'next';
}`
> Error message I am receiving: FetchError: Failed to retrieve verification certificates: request to https://www.googleapis.com/oauth2/v1/certs failed, reason: connect ETIMEDOUT
So I am just wondering what I am doing wrong here. Any help is appreciated.
Best,
Anton
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Start at the OAuth2Client.verifyIdToken entry point described in the report and trace the request to https://www.googleapis.com/oauth2/v1/certs. Reproduce the ETIMEDOUT failure and determine whether it indicates a client-library defect or an environment-specific connectivity problem; the issue is done only once a specific, actionable change is identified.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- nodejs, react-native
- Ambito
- authentication, backend
- Tipo di issue
- Bug
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100