Search code examples
node.jsnpmgoogle-apps-scriptclasp

Clasp login fails: "Error retrieving access token..."


I am trying to set up Clasp on my Windows 10 PC for Google Apps Script. When I try to log in via the command line (clasp login), a browser tab opens where I log in to google. After that, the webpage I'm redirected to says the authentication was successful; however the command line shows:

Error retrieving access token: FetchError: request to https://oauth2.googleapis.com/token failed, reason: unable to verify the first certificate

Does anyone know what might be causing this and how I can fix it?

I don't think this is a network problem as both my raspberry pi and mac authenticated just fine. I have attempted to use clasp login --no-localhost to no avail, and changing web browsers doesn't seem to help either. Removing/reinstalling node and npm made no change.

I also disabled my firewall and real-time scanning, nothing.

What I'm expecting:

C:\Users\User>clasp login

[...]

Authorization successful.

Default credentials saved to: ~/.clasprc.json (/home/pi/.clasprc.json).

What I'm getting:

C:\Users\User>clasp login

[...]

Error retrieving access token: FetchError: request to https://oauth2.googleapis.com/token failed, reason: unable to verify the first certificate

Solution

  • I'm not sure the exact issue here, but I think this is a generic issue with Google APIs using Node HTTP requests.

    Can you try to see if this solution works?

    https://github.com/request/request/issues/2061#issuecomment-182573171

    Also, I'm more active on the GitHub repo, so consider filing the issue there too: https://github.com/google/clasp/issues/new

    Thanks, Grant