Failed to retrieve verification certificates error

Trying to add google auth I faced an issue:

Here is the client code:

function onSignIn(googleUser) {
    var id_token = googleUser.getAuthResponse().id_token;
    var xhr = new XMLHttpRequest();'POST', '/google-login');
    xhr.setRequestHeader('Content-Type', 'application/json');
    xhr.onload = function() {
        // console.log('Signed in as: ' + xhr.responseText);
        if(xhr.responseText == 'success'){
            // location.assign('/profile')
    xhr.send(JSON.stringify({token : id_token}));

And here is the end point in server:'/google-login', (req,res) => {

    let token = req.body.token;

    console.log('token', token)

    async function verify() {
        const ticket = await client.verifyIdToken({
            idToken: token,
            audience: CLIENT_ID,  // Specify the CLIENT_ID of the app that accesses the backend
        const payload = ticket.getPayload();
        const userid = payload['sub'];
        // console.log("payload*********************************", console.log(payload))

        .then((e)=> {
            // res.cookie('session-token', token);
            // console.log(e)
        .catch(err => console.log(err));


I get the token in the above console log successfully but just after that I get this error:

GaxiosError: Failed to retrieve verification certificates:

enter image description here

Note: I'm using the this code.

Note 2: I'm testing this on http://localhost:4000

Read more here:

Content Attribution

This content was originally published by Sara Ree at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: