Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FetchError: Failed to retrieve verification certificates: request to https://www.googleapis.com/oauth2/v1/certs failed, reason: connect ETIMEDOUT #3028

Open
hoerlanton opened this issue Jul 20, 2022 · 2 comments
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue.

Comments

@hoerlanton
Copy link

hoerlanton commented Jul 20, 2022

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

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

@hoerlanton hoerlanton added priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue. labels Jul 20, 2022
@dudizimber
Copy link

We see this happening a lot on our services as well. There is a fairly big percentage of requests failing because of that.

Failed to retrieve verification certificates: request to https://www.googleapis.com/oauth2/v1/certs failed, reason: socket hang up

@MuzzamielAbrahams
Copy link

I am seeing a similar issue as of recently: FetchError: Failed to retrieve verification certificates: request to https://www.googleapis.com/oauth2/v1/certs failed, reason: unable to get local issuer certificate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

3 participants