Home > Net >  Go gmail api quickstart results in localhost refused to connect ERR_CONNECTION_REFUSED
Go gmail api quickstart results in localhost refused to connect ERR_CONNECTION_REFUSED

Time:11-16

I'm following the steps in site can't be reached image

Following the same quickstart but for python works flawlessly.

If I get the token via python and use it in Go quickstart, it also works. So the issue is just on the token from web retrieval.

CodePudding user response:

The issue you are having is related to the removal of oob. When that sample was originally created oob still worked. So it would display a nice web page for you where you could copy the authorization code.

That no longer works so we are forced to use http://127.0.0.1 or localhost. As your machine apparently does not have a web server running its displaying to you a 404 error.

However if you look in the URL bar you will find the authorization code you need in order to authorize your application.

The solution is to simply copy the code from the url bar. If you want to fix the 404 your going to have to figure out how to start a web server in order to host the http://127.0.0.1 from.

The python sample does this by running a local server

creds = flow.run_local_server(port=0)

Php can do it using something like this

php -S localhost:8000 -t examples/

Im not sure how that can be done with Go though.

  • Related