GoogleCloudPlatform / google-cloud-eclipse

Google Cloud Platform plugin for Eclipse
Apache License 2.0
86 stars 49 forks source link

Not able to Sign in to Google Account from Eclipse Oxygen #2148

Closed sanc-enovate closed 7 years ago

sanc-enovate commented 7 years ago

Issue : Sign in to Google is not working.

I am new to Google Cloud tools and facing problem at very first step where I need to sign in to Google account. When I hit "Sign in to Google" It opened the login process in external browser(Chrome), After login and giving permission, It redirects to localhost:RANDOM_PORT/Callback?code=xxxxxx

This URL doesn't exist and showing "This site can’t be reached", standard google chrome page ,

In eclipse, Showing processing dialog window with Cancel option.

Not sure why callback redirection is to a Random localhost port ?

Additional information: I tried with Safari and result is same.

chanseokoh commented 7 years ago

Can you clarify if what you see is the literal string "RANDOM_PORT"? If so, that's certainly a bug. (However, it is correct that it should be some random localhost port.)

sanc-enovate commented 7 years ago

It is some random localhost port like 60456, 54329 and so on

chanseokoh commented 7 years ago

I see. At least it is correct that it redirects to a random localhost port. When the login browser launches, our CT4E plugin also listens from the port locally to receive the code value. Let me check what could go wrong.

chanseokoh commented 7 years ago

The fact that you see actual random port numbers very likely suggests that the local web server is up and running (in-process, and not as a separate process).

I suspect your browser is blocked from accessing "http://localhost", perhaps due to your proxy settings. Can you update your browser proxy settings so that localhost addresses bypass the proxy?

sanc-enovate commented 7 years ago

I doubt about proxy, my node JS apps run smoothly on different port, web server works fine

Any other thought?

briandealwis commented 7 years ago

Are you behind a firewall or anti-virus?

Could you check your <workspace>/.metadata/.log?

chanseokoh commented 7 years ago

First, let's check if the local web server is listening, and then try to connect to the local web server from other clients than browsers, such as wget in the terminal.

Let Eclipse be the only Java process. netstat -tlnp will give you listening TCP ports with process names. I recommend restarting Eclipse before doing this. Normally, there shouldn't be any Java process.

$ netstat -tlnp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:30003         0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:9557          0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.1.1:53            0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:9558          0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:9559          0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:45596           0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:8103            0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:999           0.0.0.0:*               LISTEN      -               
tcp6       0      0 :::31337                :::*                    LISTEN      -               
tcp6       0      0 :::44681                :::*                    LISTEN      -               
tcp6       0      0 :::12589                :::*                    LISTEN      -               
tcp6       0      0 :::111                  :::*                    LISTEN      -               
tcp6       0      0 :::9554                 :::*                    LISTEN      -               
tcp6       0      0 :::9555                 :::*                    LISTEN      -               
tcp6       0      0 ::1:9557                :::*                    LISTEN      -               
tcp6       0      0 ::1:9558                :::*                    LISTEN      -               
tcp6       0      0 :::22                   :::*                    LISTEN      -               
tcp6       0      0 ::1:9559                :::*                    LISTEN      -               
tcp6       0      0 ::1:631                 :::*                    LISTEN      -               
tcp6       0      0 :::3900                 :::*                    LISTEN      -               
tcp6       0      0 :::3901                 :::*                    LISTEN      -               
tcp6       0      0 :::8224                 :::*                    LISTEN      -               
tcp6       0      0 :::12513                :::*                    LISTEN      -               
tcp6       0      0 :::32100                :::*                    LISTEN      -               
tcp6       0      0 :::32101                :::*                    LISTEN      -               
tcp6       0      0 :::8103                 :::*                    LISTEN      -               

Then, click on the login button in Eclipse. When the "Sign in to Google" dialog pops up, check which port is open. There will be one Java process:

(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:30003         0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:9557          0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.1.1:53            0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:9558          0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:9559          0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:45596           0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:8103            0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:999           0.0.0.0:*               LISTEN      -               
tcp6       0      0 :::31337                :::*                    LISTEN      -               
tcp6       0      0 :::44681                :::*                    LISTEN      -               
tcp6       0      0 :::12589                :::*                    LISTEN      -               
tcp6       0      0 :::111                  :::*                    LISTEN      -               
tcp6       0      0 :::9554                 :::*                    LISTEN      -               
tcp6       0      0 :::9555                 :::*                    LISTEN      -               
tcp6       0      0 127.0.0.1:41237         :::*                    LISTEN      101879/java     
tcp6       0      0 ::1:9557                :::*                    LISTEN      -               
tcp6       0      0 ::1:9558                :::*                    LISTEN      -               
tcp6       0      0 :::22                   :::*                    LISTEN      -               
tcp6       0      0 ::1:9559                :::*                    LISTEN      -               
tcp6       0      0 ::1:631                 :::*                    LISTEN      -               
tcp6       0      0 :::3900                 :::*                    LISTEN      -               
tcp6       0      0 :::3901                 :::*                    LISTEN      -               
tcp6       0      0 :::8224                 :::*                    LISTEN      -               
tcp6       0      0 :::12513                :::*                    LISTEN      -               
tcp6       0      0 :::32100                :::*                    LISTEN      -               
tcp6       0      0 :::32101                :::*                    LISTEN      -               
tcp6       0      0 :::8103                 :::*                    LISTEN      -               

So, you now know there is a Java process listening on port 41237. Try

$ wget 127.0.0.1:41237 $ wget localhost:41237

If it returns 404, then at least we know the server is running and it's the browser problem.

HTTP request sent, awaiting response... 404 Not Found
2017-07-14 14:04:37 ERROR 404: Not Found.
chanseokoh commented 7 years ago

I sometimes see Eclipse listen on some port on its own, so I recommend you check netstat multiple times by clicking on the login button and cancelling the "Sign in to Google" dialog.

chanseokoh commented 7 years ago

Also, hitting /Callback?error=whatever will return 200 or 302, so this is the sure thing to know if the server is the right one. When returning 200 or 302 with this URL, the server dies, and the "Sign in to Google" dialog in Eclipse will disappear.

$ wget 127.0.0.1:60039/Callback?error=killtest
--2017-07-14 14:18:16--  http://127.0.0.1:60039/Callback?error=killtest
Connecting to 127.0.0.1:60039... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘Callback?error=killtest’

    [ <=>                                                                                                                                             ] 159         --.-K/s   in 0s      

2017-07-14 14:18:16 (20.7 MB/s) - ‘Callback?error=killtest’ saved [159]

(BTW, delete the unnecessary file that wget downloaded.)

sanc-enovate commented 7 years ago

Netstat stuff did the trick,

Here are the steps that help to resolve the issue (Steps for Mac):-

  1. Click on "sign in to google"
  2. Run below command on terminal sudo lsof -i -n -P | grep TCP
  3. Check the IP and port with program name eclipse
  4. When the callback url returned on browser, simply replace localhost with the IP address noted in step 3 and press Enter
  5. We are good.

What is the root cause :

Google sign-in process run a local web server on 192.168..:45678 in place of (127.0.0.1/localhost):45678 .

Thank you for pointing towards right direction

Best Regards Sanjeev Choudhary http://one.enovate-it.com/ http://www.enovate-it.com/

Disclaimer: This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system.Our company accepts no liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided, unless that information is subsequently confirmed in writing. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.

chanseokoh commented 7 years ago

Seems like this can happen when there are multiple localhost interfaces. We need to let Jetty return the actual host here:

https://github.com/google/google-oauth-java-client/blob/dev/google-oauth-client-jetty/src/main/java/com/google/api/client/extensions/jetty/auth/oauth2/LocalServerReceiver.java#L129