node.jsgoogle-apigoogle-oauthgoogle-sheets-api

Google Sheets API localhost refused to connect when authorizing


I was going through the Quickstart for Nodejs and every time I run the code, I get this.

enter image description here

I've tried things like rebooting the computer, making new credentials, making new projects but nothing worked.

What might be the problem?

Also, I'm using a mac.


Solution

  • If you have the redirection pointing to your localhost you have the authorization code available inside the URL:

    http://localhost/?code=<copethiscodetotheconsole>&scope=[listofscopes]
    

    Remember to enable the API inside the https://console.cloud.google.com/apis/library?project=<your_project_name>

    Documentation: