Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

wrangler login just get stuck Waiting for API token... #1703

Closed
rib opened this issue Dec 28, 2020 · 52 comments
Closed

wrangler login just get stuck Waiting for API token... #1703

rib opened this issue Dec 28, 2020 · 52 comments
Labels
bug Something isn't working onboarding Issues with installation or login regression Something is broken, but works in previous releases

Comments

@rib
Copy link

rib commented Dec 28, 2020

🐛 Bug Report

I found this closed issue #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.

@siba2893
Copy link

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

@nolandubeau
Copy link

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).

@DariuszOstolski
Copy link

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

@nolandubeau
Copy link

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.

@danbars
Copy link

danbars commented Jan 8, 2021

Same issue here too.
Chrome 87 on Mac 10.15.5

@ClementParis016
Copy link

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

@lemaguilera
Copy link

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

@lougayou
Copy link

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!

@daggy1234
Copy link

Same issue on macos

@yucongo
Copy link

yucongo commented Feb 4, 2021

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.

@omarabid
Copy link

omarabid commented Feb 5, 2021

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

@tongyifan
Copy link

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: ..."

@Electroid Electroid added bug Something isn't working onboarding Issues with installation or login labels Feb 22, 2021
@xortive
Copy link
Contributor

xortive commented Mar 2, 2021

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.

@danbars
Copy link

danbars commented Mar 3, 2021

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.

@samarpanda
Copy link

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.

@daggy1234
Copy link

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

@SergkeiM
Copy link

SergkeiM commented Mar 12, 2021

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

@churchthecat
Copy link

churchthecat commented Mar 13, 2021

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.

@Electroid Electroid added the regression Something is broken, but works in previous releases label Mar 18, 2021
@antholeole
Copy link

antholeole commented Mar 21, 2021

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.

@intellix
Copy link

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

@fawazahmed0
Copy link

same issue here

@fawazahmed0
Copy link

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

@nilslice
Copy link
Contributor

@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?

@Yrlish
Copy link

Yrlish commented Apr 28, 2021

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

@nilslice
Copy link
Contributor

@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?

@Yrlish
Copy link

Yrlish commented Apr 28, 2021

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

haha yes indeed, very annoying 😛

Yes, both environments logged in using wrangler login without any problems when I just tested. First environment created a token and received it successfully, second environment replaced the token and received it successfully.

@JoyceBabu
Copy link

@nilslice I am also facing this issue. Please find the requested details below.

  1. which version of wrangler are you running? wrangler --version

👷 ✨ wrangler 1.16.1

  1. when wrangler login remained stuck waiting on the token, was this your first time logging in via CLI?

First time.

  1. 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?

Even the directory was not created. I tried creating the directory as @timhaak and retried wrangler login, but it still did not work.

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.

https://pastebin.com/1D86d5Nc

@victorbjorklund
Copy link

I still have this issue using wrangler 1.17.0 on a Mac. Nothing gets written to ~/.wrangler/config/. Terminal just stuck at "Waiting for API token..." forever while website says "Wrangler is now authorized with a new API Token. You can now close this page."

@matt-allan
Copy link

matt-allan commented Jun 17, 2021

I'm seeing this too. Tested with yarn, npm and cargo wrangler installs, and Safari, Chromium, and Firefox as the default browser on two different macs. MacOS Big Sur 11.4 (20F71). Wrangler 1.17.0. This is my first time logging in.

Here's the log output

Edit: this workaround worked for me.

@alanshaw
Copy link

I had the same issue using Firefox as default browser. I copied the link into Chrome and then was able to login.

@leoplct
Copy link

leoplct commented Jun 24, 2021

I've run mkdir -p ~/.wrangler/config/ but I got stuck at "Waiting for API token...".

@khromov
Copy link

khromov commented Jun 30, 2021

My problem was that I tried running wrangler through npx, so for example npx @cloudflare/wrangler login does not work.

@nilslice
Copy link
Contributor

@khromov - thanks for reporting. did you also experience wrangler getting stuck at "Waiting for API token...", or did you get different output?

@khromov
Copy link

khromov commented Jun 30, 2021

@nilslice Yes, it was stuck at "Waiting for API token...".

I was running the command from a VSCode prompt using Windows 10 and Ubuntu on WSL2. The browser did not open automatically, I had to paste the URL manually.

(The browser did not open automatically when installed via -g either, but logging in worked fine.)

@nneil
Copy link

nneil commented Jul 7, 2021

Same problem under Windows 10. The window opens and the token is generated, but the Waiting for API token... never returns. I generated an API token manually and added it with wrangle config. It worked well enough to go through the quickstart.

@JIBSIL
Copy link

JIBSIL commented Jul 30, 2021

My problem was that there were too many API tokens (or maybe the name was conflicting?). As soon as I removed all of my API tokens that I wasn't using with the same name, it cleared up.

@adammonago
Copy link

Same issue here. using chrome on osx. @nolandubeau workaround fixed the issue for me as well!

@neerolyte
Copy link

neerolyte commented Aug 10, 2021

$ wrangler --version
wrangler 1.17.0

This is my first time attempting to login via the CLI.

$ ls -la ~/.wrangler/config/
total 8
drwxrwxr-x 2 dschoen dschoen 4096 Aug 10 14:39 .
drwxrwxr-x 5 dschoen dschoen 4096 Aug 10 14:38 ..
$ RUST_LOG=debug wrangler login
[2021-08-10T04:42:49Z INFO  wrangler::settings::global_config] No $WRANGLER_HOME detected, using $HOME
Allow Wrangler to open a page in your browser? [y/n]
y
💁  Opened a link in your default browser: https://dash.cloudflare.com/wrangler?key=...
[2021-08-10T04:42:51Z DEBUG eventual::core] Core::producer_ready; state=State[count=0; consuming=false; producing=false; lifecycle=New]
[2021-08-10T04:42:51Z DEBUG eventual::core]   - transitioned from State[count=0; consuming=false; producing=false; lifecycle=New] to State[count=0; consuming=false; producing=false; lifecycle=ProducerWait]
⠁   Waiting for API token...
[2021-08-10T04:42:51Z DEBUG eventual::core] Core::consumer_await
[2021-08-10T04:42:51Z DEBUG eventual::core] Core::consumer_ready; state=State[count=0; consuming=false; producing=false; lifecycle=ProducerWait]
[2021-08-10T04:42:51Z DEBUG eventual::core] Core::consumer_wait; state=State[count=0; consuming=false; producing=false; lifecycle=ProducerWait]
[2021-08-10T04:42:51Z DEBUG eventual::core]   - transitioned from State[count=0; consuming=false; producing=false; lifecycle=ProducerWait] to State[count=1; consuming=false; producing=false; lifecycle=ConsumerWait]
[2021-08-10T04:42:51Z DEBUG eventual::core]   - notifying producer
[2021-08-10T04:42:51Z DEBUG eventual::core] Core::notify_producer
[2021-08-10T04:42:51Z DEBUG eventual::core]   - transitioned from State[count=1; consuming=false; producing=false; lifecycle=ConsumerWait] to State[count=1; consuming=false; producing=true; lifecycle=ConsumerWait]
[2021-08-10T04:42:51Z DEBUG eventual::core]   - Invoking producer; state=State[count=1; consuming=false; producing=true; lifecycle=ConsumerWait]
[2021-08-10T04:42:51Z DEBUG eventual::stream] Sender::poll; is_ready=true
[2021-08-10T04:42:51Z DEBUG eventual::core] Core::producer_poll; state=State[count=1; consuming=false; producing=true; lifecycle=ConsumerWait]
[2021-08-10T04:42:51Z DEBUG syncbox::thread_pool] running task; tp-state=Running; worker_count=0
[2021-08-10T04:42:51Z DEBUG syncbox::thread_pool] spawning new worker thread
[2021-08-10T04:42:51Z DEBUG syncbox::thread_pool] task submitted to queue
[2021-08-10T04:42:51Z DEBUG eventual::core]   - Producer invoked; state=State[count=1; consuming=false; producing=false; lifecycle=ConsumerWait]
[2021-08-10T04:42:51Z DEBUG eventual::core] Core::consumer_await - parking thread
⠒   Waiting for API token...
[2021-08-10T04:42:52Z DEBUG syncbox::thread_pool] worker processing task
[2021-08-10T04:42:52Z DEBUG syncbox::thread_pool] ~~ running scheduled task
[2021-08-10T04:42:52Z DEBUG eventual::core] Core::complete; state=State[count=1; consuming=false; producing=false; lifecycle=ConsumerWait]; success=true; last=false
[2021-08-10T04:42:52Z DEBUG eventual::core]   - transitioned from State[count=1; consuming=false; producing=false; lifecycle=ConsumerWait] to State[count=1; consuming=false; producing=false; lifecycle=Ready]
[2021-08-10T04:42:52Z DEBUG eventual::core]   - notifying consumer
[2021-08-10T04:42:52Z DEBUG eventual::core] Core::consumer_await - unparking thread
[2021-08-10T04:42:52Z DEBUG eventual::core]   - consumer notified
[2021-08-10T04:42:52Z DEBUG eventual::core] Core::producer_ready; state=State[count=1; consuming=false; producing=false; lifecycle=Ready]
[2021-08-10T04:42:52Z DEBUG eventual::core]   - transitioned from State[count=1; consuming=false; producing=false; lifecycle=Ready] to State[count=1; consuming=false; producing=false; lifecycle=ReadyProducerWait]
[2021-08-10T04:42:52Z DEBUG syncbox::thread_pool] worker waiting for task
[2021-08-10T04:42:52Z DEBUG eventual::core] Core::consumer_poll; state=State[count=1; consuming=true; producing=false; lifecycle=Ready]
[2021-08-10T04:42:52Z DEBUG eventual::core]   - transitioned from State[count=1; consuming=false; producing=false; lifecycle=ReadyProducerWait] to State[count=1; consuming=false; producing=false; lifecycle=ProducerWait] (consuming value)
⠋   Waiting for API token...
[2021-08-10T04:43:22Z DEBUG eventual::core] Core::cancel; state=State[count=1; consuming=false; producing=false; lifecycle=ProducerWait]
[2021-08-10T04:43:22Z DEBUG eventual::core]   - transitioned from State[count=1; consuming=false; producing=false; lifecycle=ProducerWait] to State[count=1; consuming=false; producing=false; lifecycle=Canceled]
[2021-08-10T04:43:22Z DEBUG eventual::core] Core::notify_producer
[2021-08-10T04:43:22Z DEBUG eventual::core]   - transitioned from State[count=1; consuming=false; producing=false; lifecycle=Canceled] to State[count=1; consuming=false; producing=true; lifecycle=Canceled]
[2021-08-10T04:43:22Z DEBUG eventual::core]   - Invoking producer; state=State[count=1; consuming=false; producing=true; lifecycle=Canceled]
[2021-08-10T04:43:22Z DEBUG eventual::stream] Sender::poll; is_ready=false
[2021-08-10T04:43:22Z DEBUG eventual::core] Core::producer_poll; state=State[count=1; consuming=false; producing=true; lifecycle=Canceled]
[2021-08-10T04:43:22Z DEBUG syncbox::thread_pool] shutdown; tp-state=Running; target=Shutdown; worker_count=1
[2021-08-10T04:43:22Z DEBUG syncbox::thread_pool]   enqueuing no-ops; count=1
[2021-08-10T04:43:22Z DEBUG syncbox::thread_pool] received no-op token -- shutting down
Error: error sending request for url (https://api.cloudflare.com/client/v4/workers/token): operation timed out

Caused by:
    operation timed out

Wrangler is not actually opening the link in any browser I have been able to find, but if I click the link presented in the terminal I end up getting to the Wrangler is now authorized with a new API Token\nYou can now close this page. prior to the timeout occuring in the CLI.

Edit: I upgraded using npm i @cloudflare/wrangler -g to 1.19.0 and get the same result.

@vishal-1408
Copy link

vishal-1408 commented Aug 16, 2021

I faced the same issue in my laptop running windows 10. I found a simple workaround for this issue. We can create custom tokens in the Cloudflare account with the settings same as the generated token. Enter this token manually using the wrangler config command and you are good to go.

@zaerl
Copy link

zaerl commented Aug 19, 2021

I solved this issue removing the .wrangler/ folder from the home directory and trying again. The CLI will generate a new default.toml file.

@famzah
Copy link

famzah commented Aug 21, 2021

I had to delete the two existing tokens in the Cloudflare Dashboard, in order to fix this.

@brandiqa
Copy link

brandiqa commented Sep 8, 2021

Using the latest version of Wrangler 1.19.2 in Zorin OS(Ubuntu distro) and wrangler login doesn't work as expected. Had to resort to the manual method.

@falcon03
Copy link

Another user facing this issue: wrangler login does not work. Tested with wrangler 2.0.14...

Checking from the cloudflare dashboard, it looks like wrangler login does not generate an api token at all!

@fhirfly
Copy link

fhirfly commented Jul 23, 2022

my wrangler on Ubuntu hangs no matter if its login or publish. login gets a token (writes to .wrangler/config) but then hangs. same thing when I run publish, just hangs. No way to kill it.

@mythz
Copy link

mythz commented Oct 24, 2022

The docs for using curl in Using wrangler login on a remote machine didn't work for me, what did was opening port forwarding to the remote server which lets me follow their OAuth in my desktop browser and successfully redirect back to wrangler login running on my remote server:

ssh -L 8976:0.0.0.0:8976 -N name@server

@IgnisDa
Copy link

IgnisDa commented Feb 3, 2023

I had this problem in my devcontainer where I could not forward port 8976 for some reason. Here is what worked for me:

  1. Run wrangler login
  2. Go through all the steps until you get to the page which tries to connect to http://localhost:8976/oauth/...
  3. Run docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name to get the IP address of the running container
  4. Replace localhost in the browser URL you got in step 2 with the IP address you got in step 3 and then reload the page.

@JacobMGEvans
Copy link
Contributor

Thanks for creating this issue! Wrangler v1 is now deprecated and support is only being provided for critical updates or security concerns. As such, we are closing this PR.

New versions of Wrangler are maintained in the workers-sdk repo. If you are running into a similar issue with wrangler v2, please report it or create a new PR in the workers-sdk repo. For more info about wrangler v1 deprecation, please check out our blog post.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working onboarding Issues with installation or login regression Something is broken, but works in previous releases
Projects
None yet
Development

No branches or pull requests