shorebird icon indicating copy to clipboard operation
shorebird copied to clipboard

fix: Shorebird login exception - state did not match

Open ThomasVuNguyen opened this issue 1 year ago • 2 comments
trafficstars

App ID: N/A

When running "shorebird login" to initialize, opening the link and clicking on the right email, I got a local host screen with the error Exception: Invalid response from server (state did not match).

A clear and concise description of what the bug is.

Steps To Reproduce

  1. Install shorebird like normal
  2. run 'shorebird login'
  3. Open the link given & click on the right email
  4. See error, should see as below image image

ThomasVuNguyen avatar Apr 15 '24 05:04 ThomasVuNguyen

Hi @ThomasVuNguyen 👋 Thanks for opening an issue!

Does this issue persist when you close all browser tabs and try again? Have you tested in an incognito window? If you're still having trouble can you let us know what operating system and browser you're using? Thanks!

felangel avatar Apr 15 '24 05:04 felangel

I have not tried in cognito but I found this:

When I run shorebird login on the android studio terminal in the flutter project folder -> fail

But when I run login on a PowerShell, it worked!

ThomasVuNguyen avatar Apr 15 '24 06:04 ThomasVuNguyen

I wonder if there is some restriction in certain terminals about opening ports? My (not precise) understanding is how the oauth flow works is:

  1. The CLI makes a request to Google, gets a URL.
  2. The CLI opens that URL in a web browser.
  3. The user does the OAuth flow from that URL.
  4. On completion of the flow, it posts to https://localhost:1234/ (or whatever the port number) which was negotiated with Google in step 1.
  5. The CLI takes the result from the post and probably talks to google again. 🤷

Where we typically see oauth flows fail are either if the User's network can't talk to oauth.google.com (e.g. the page load fails in the web browser). Or sometimes there seems to be some sort of firewall which prevents oauth.google.com from posting back to localhost. This can also happen from edits to /etc/host (which in today's world you basically never want to do).

eseidel avatar May 30 '24 21:05 eseidel

Since this one is resolved, I think we'll close this for now and wait for a new report. Thank you for reporting!

eseidel avatar May 30 '24 21:05 eseidel