wrangler-legacy icon indicating copy to clipboard operation
wrangler-legacy copied to clipboard

wrangler login just get stuck `Waiting for API token...`

Open rib opened this issue 3 years ago • 49 comments

🐛 Bug Report

I found this closed issue https://github.com/cloudflare/wrangler/issues/1514 has a number of people reporting this same issue with the tool hanging, but looking at that original issue which was closed in October it looks like was for a different problem.

Environment

  • operating system: Ubuntu 20.04.1 LTS
  • output of rustc -V: rustc 1.47.0 (18bf6b4f0 2020-10-07)
  • output of node -v: v10.19.0
  • output of wrangler -V: wrangler 1.12.3
  • contents of wrangler.toml
name = "test"
type = "javascript"
account_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
workers_dev = true
route = ""
zone_id = ""

(Simply created via wrangler generate test)

Steps to reproduce

run wrangler login

What did you expect to see?

After authorizing Cloudflare via the opened web browser, after the token is created, I expected wrangler login to continue.

What did you see instead?

I do see the browser open (Firefox) and I'm able to authorize the creation of a new token which does happen successfully but the wrangler login tool remains stuck forever with Waiting for API token...

Since it was suggested in #1514 that it might make a difference to delete existing tokens first I also tried deleting all tokens but that didn't seem to make a difference for me.

rib avatar Dec 28 '20 21:12 rib

This happens to me too. Can use wrangle login cause it gets stucked. :/

siba2893 avatar Dec 30 '20 18:12 siba2893

I am experiencing the same issue. I wonder if it has to do with the fact that I have two cloudflare accounts. When I do wrangler whoami, I see the old account that I do not want to use. It could be useful to have a wrangler logout command which other CLI's (like Firease-CLI) have. At first I thought this may have been an issue with the api token callback back to VSCode, but the error is also happening in Terminal (on MacOS).

nolandubeau avatar Jan 04 '21 21:01 nolandubeau

I have the same issue, I have one cloudflare account. I'm using Ubuntu with Firefox as default browser and containers extension.

DariuszOstolski avatar Jan 04 '21 21:01 DariuszOstolski

I was able to get the login and auth callback from the browser to work just now. Not sure if this works for anyone else, but I ran the command wrangler config --api-key, which is the command to set the global api key, and which is not recommended. I cancelled out from that command and then ran wrangler login again, and it authenticated successfully. Could have been chance, but maybe that might work for someone else as the command may have cleared something from the config.

nolandubeau avatar Jan 04 '21 21:01 nolandubeau

Same issue here too. Chrome 87 on Mac 10.15.5

danbars avatar Jan 08 '21 22:01 danbars

I just encountered the same issue, weirdly enough @nolandubeau's workaround worked for me too (thanks ❤️ )

ClementParis016 avatar Jan 13 '21 09:01 ClementParis016

I was able to get the login and auth callback from the browser to work just now. Not sure if this works for anyone else, but I ran the command wrangler config --api-key, which is the command to set the global api key, and which is not recommended. I cancelled out from that command and then ran wrangler login again, and it authenticated successfully. Could have been chance, but maybe that might work for someone else as the command may have cleared something from the config.

It works! thanks

lemaguilera avatar Jan 16 '21 03:01 lemaguilera

I ran into the same issue: Ubuntu 20.04 Chrome 88.0.4324.96 wrangler 1.13.0 node v14.4.0

Thanks @nolandubeau , your workaround fixed the issue!

lougayou avatar Jan 23 '21 21:01 lougayou

Same issue on macos

daggy1234 avatar Jan 26 '21 15:01 daggy1234

Sometimes if you already logged in and tried to log in again, you'll get stuck. In any case, that was what happen to me with wrangler 1.13.0 in ubuntu 19.

I got stuck with the same message Waiting for API token... and tried many methods suggsested from the net. Nothing worked. It turned out I already logged in last time.

To find out whether you already logged in, do wrangler whoami If your account name and id show up, you are good to go.

yucongo avatar Feb 04 '21 06:02 yucongo

Same issue for freshly installed wrangler (using Cargo). Version 1.13.0. I'm using Archlinux (Kernel version 5.10.11)

omarabid avatar Feb 05 '21 00:02 omarabid

Same issue. I fixed it by fill API token manually.

  1. Use wrangler login to open login link.
  2. Press F12, then switch it to network tab.
  3. Press "Authorize Wrangler", then wait it success.
  4. Check the lastest request, find a request like https://dash.cloudflare.com/api/v4/user/tokens/SOME_HEX_STRING_HERE/value , then find your API token in the response.
  5. Run command wrangler config, paste the API token into it and press Enter, then you will get "Successfully configured. You can find your configuration file at: ..."

tongyifan avatar Feb 05 '21 05:02 tongyifan

Hey folks, are y'all reaching a page that looks like: Screenshot from 2021-03-02 09-38-42

and after clicking "Authorize Wrangler", wrangler login is still stuck?

If you aren't reaching this page, try logging in and opening the link that wrangler login prints to your console.

If you are clicking "Authorize Wrangler" and wrangler login is still getting stuck, I'd like to get more information to reproduce this problem.

xortive avatar Mar 02 '21 15:03 xortive

Hi @xortive , I reach this page, but after clicking the authorize button, the cli is still stuck. Happens consistently on all worker projects that I have, workers and worker-sites. Here's one toml for example

name = "form-data-app"
type = "webpack"
account_id = "c4axxxxxxxxxx710"
workers_dev = false
route = "https://app.form-data.com/*"
zone_id = "f6bxxxxxxxxxxxxxxxxe15"

[site]
bucket = "./dist/pwa"
entry-point = "workers-site"

Happens on Chrome 88 on Mac 10.15.5, but Also happened on previous versions of both mac and chrome. Let me know what other details do you need.

danbars avatar Mar 03 '21 06:03 danbars

Hey folks, are y'all reaching a page that looks like: Screenshot from 2021-03-02 09-38-42

and after clicking "Authorize Wrangler", wrangler login is still stuck?

If you aren't reaching this page, try logging in and opening the link that wrangler login prints to your console.

If you are clicking "Authorize Wrangler" and wrangler login is still getting stuck, I'd like to get more information to reproduce this problem.

Yes, after clicking the wrangler login it is stuck. Let me know what info do you need. I can share.

samarpanda avatar Mar 05 '21 18:03 samarpanda

After clicking it got stuck, I was able to fix it by manually setting it a long time ago. On macos with homebrew.

daggy1234 avatar Mar 08 '21 04:03 daggy1234

Have same issue,

After calling wrangler config added token manually.

Calling wrangler whoami outputs correct email and token.

But when runing wrangler dev - shows You have not provided your Cloudflare credentials. Anyone had same issue?

Note: temporary downgraded to 10.0.3

SergkeiM avatar Mar 12 '21 07:03 SergkeiM

Managed to login , by wrangler login ->authorize selecting roll on the API Token page for wrangler copy token wrangler config ->paste token

whoami gives correct output then: wrangler dev gives: Error: wrangler.toml not found; run wrangler init to create one.

running wrangler init: you can copy your account_id below "account details" Error: field account_id is required to deploy to workers.dev

edited wrangler.toml with account id.

└─$ wrangler dev 130 ⨯ thread '' panicked at 'called Result::unwrap() on an Err value: Io(Os { code: 28, kind: Other, message: "No space left on device" })', src/watch/mod.rs:39:22 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

However I managed to create a test worker with wrangler generate. A reboot got rid of the error message.

churchthecat avatar Mar 13 '21 12:03 churchthecat

Extra info - may be browser dependent? I attempted three times in Safari, both times I got stuck on "waiting for API token..." switched my default browser to Firefox, tried again, and it worked fine.

May be due to other external factors and just so happened that it worked 1 / 4 times, but might be an avenue worth investigating.

ran wrangler login in integrated terminal on VScode, macOS Big Sur, wrangler 1.11.0.

antholeole avatar Mar 21 '21 21:03 antholeole

Was trying this from VSCode Integrated Terminal to Chrome and it was stuck for me. I tried it in OSX Terminal to Chrome and then it worked as expected

intellix avatar Mar 22 '21 11:03 intellix

same issue here

fawazahmed0 avatar Apr 10 '21 18:04 fawazahmed0

Same issue. I fixed it by fill API token manually.

1. Use `wrangler login` to open login link.

2. Press F12, then switch it to network tab.

3. Press "Authorize Wrangler", then wait it success.

4. Check the lastest request, find a request like `https://dash.cloudflare.com/api/v4/user/tokens/SOME_HEX_STRING_HERE/value` , then find your API token in the response.

5. Run command `wrangler config`, paste the API token into it and press Enter, then you will get "Successfully configured. You can find your configuration file at: ..."

Thanks, this worked

fawazahmed0 avatar Apr 10 '21 23:04 fawazahmed0

After the token was created I just aborted the login command. Then find the token here. Next to the token is a button with 3 dots. Click and select 'roll'. Now you get a new token that you can use with wrangler config

roelandmoors avatar Apr 11 '21 10:04 roelandmoors

From my side, it worked once I created the following folder.

mkdir -p ~/.wrangler/config/

timhaak avatar Apr 13 '21 10:04 timhaak

Same issue using VSCode and Brave. Kind of frustrating when you're onboarding ;)

https://github.com/cloudflare/wrangler/issues/1703#issuecomment-817285470 does the trick

jide avatar Apr 13 '21 20:04 jide

Same issue on macos 11.2.3 with brave.

RemiKalbe avatar Apr 27 '21 14:04 RemiKalbe

Hey all - we're currently looking into this issue & have some questions if anyone can share details on the following:

  1. which version of wrangler are you running? wrangler --version
  2. when wrangler login remained stuck waiting on the token, was this your first time logging in via CLI?
  3. if you got the "Wrangler is now authorized with a new API Token" screen but still observed the CLI to hang, can you check if you ended up getting anything written to ~/.wrangler/config/default.toml or the equivalent path on your OS?

Additionally: if you can retry the login flow with logging enabled, and share the output (removing any tokens if they are visible), please do by running:

RUST_LOG=debug wrangler login

Thank you -- lots of weird little edge cases here, so all details are really helpful.

nilslice avatar Apr 28 '21 15:04 nilslice

@timhaak, re:

From my side, it worked once I created the following folder. mkdir -p ~/.wrangler/config/

Did the CLI show any permission error indicating that it couldn't write to disk or create any files?

And to confirm, you created that directory, and then re-executed wrangler login, which worked as expected?

nilslice avatar Apr 28 '21 15:04 nilslice

Hi @nilslice!

Just because you wanted me to test, wrangler doesn't seem to get stuck as described in #1883. Although, the token got replaced, so it invalidated one environment when logging into another.

  1. 1.16.1
  2. Yes

Yrlish avatar Apr 28 '21 16:04 Yrlish

@Yrlish - thank you!

Just because you wanted me to test, wrangler doesn't seem to get stuck as described in #1883.

😄 haha that seems to be the way these things work!

So both devices are now able to use wrangler login ? The device change should invalidate the other, but it shouldn't hang when trying to revalidate on the second device. Are you able to get the second device to auth as expected, or does it still hang?

nilslice avatar Apr 28 '21 16:04 nilslice