Search code examples
gmail-api

GMail API Node.js quickstart - ERR_CONNECTION_REFUSED


I am trying the GMail API Node.js quickstart on Windows 10.

I do get the expected

Authorisation Message.

However when I visit the url I get

ERR_CONNECTION_REFUSED

for http://localhost/?code=4/xxxxxxxxxxxxxxxxxx&scope=https://www.googleapis.com/auth/gmail.radonly

I get this error after going through 'This app isn't verified'/'Advanced > Go to {Project Name} (unsafe)'. message.

No Proxy active and also tried with AntiVirus disabled.

Any ideas what the problem could be? Thanks.


Solution

  • The issue you are having is that you are runing a Authorization credentials for a desktop application. Google made a change recently which deprecated the oob redirect. This means that now you need to use localhost or 127.0.0.1 as a redirect endpoint for installed applications.

    Resulting them in returning the authorization code back to the browser showing site can not be reached because your not running a web app you are running an installed application.

    If you check the url the authorization code you are looking for to add to your code can be found there. just take that code and submit it where it asks for it.

    Enter the code from that page here:
    

    There is currently no other option and no way to fix this unless you want to start up a web server in node. basicly its working as intended and Google is in the process of updating all the Javascript samples to reflect that.