question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

🐛 BUG: Wrangler publish returning generic error: Authentication error [code: 10000]

See original GitHub issue

What version of Wrangler are you using?

2.0.27

What operating system are you using?

Mac/Linux

Describe the Bug

I’m trying to build a CI/CD pipeline in CircleCI to publish a worker script to cloudflare, but it’s failing in the pipeline. It was working on my mac yesterday, but at the time of writing, it’s not even working on my local.

(Side note: when it was working yesterday on my local, at times it was launching a browser window for me to login, even though I have been following https://developers.cloudflare.com/workers/wrangler/ci-cd/ )

my toml file looks like this

name = "wrangler"
main = "src/index.js"
compatibility_date = "2022-08-22"
account_id = "xxxx"

[vars]
CLOUDFLARE_API_TOKEN = "xxx"
NAME = "CanaryProcessCookie"
DRUPAL_URL = "xxxx"
NEXT_JS_URL = "xxxx"
DRUPAL_COOKIE = "drupal"
NEXT_JS_COOKIE = "next"
NEXT_JS_CANARY_WEIGHT = 0.5

(my api token has underscores in it, not sure if that’s relevant)

My Api token has the following permissions

  • cloudflare pages - Edit
  • workers R2 storage - Edit
  • Workers Tail - Read
  • Workers KV Storage - Edit
  • Workers Scripts - Edit (initially i had just this, i thought this was all i needed)
  • Account Settings - Read

I have installed wrangler just within the scope of the project, so i am running the following command to publish: npx wrangler publish src/index.js --name worker-preprod

and i get this output/error:

Your worker has access to the following bindings:

  • Vars:
    • CLOUDFLARE_API_TOKEN: “xxxx”
    • NAME: “CanaryProcessCookie”
    • DRUPAL_URL: “xxxx”
    • NEXT_JS_URL: “xxxx”
    • DRUPAL_COOKIE: “drupal”
    • NEXT_JS_COOKIE: “next”
    • NEXT_JS_CANARY_WEIGHT: “0.5” Total Upload: 0.96 KiB / gzip: 0.46 KiB

✘ [ERROR] A request to the Cloudflare API (/accounts/xxxx/workers/scripts/worker-preprod) failed.

Authentication error [code: 10000]

How come i’m not able to publish? and what does this error mean?

Any help is appreciated 😃 Thanks

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
threepointonecommented, Aug 23, 2022

[vars] is for configuration that’s available inside the worker itself. But CLOUDFLARE_API_TOKEN is a proper “environment variable” on the system that’s read during builds and deploys. You need to pass CLOUDFLARE_API_TOKEN as an environment variable (For circle ci, I found these docs that show how to do so https://circleci.com/docs/env-vars)

0reactions
penalosacommented, Sep 20, 2022

I’m closing this issue as it seems the root issue is resolved. To tie together some of the notes from the thread though:

  • The [vars] section in wrangler.toml is for variables that will be exposed to your worker. Environment variables like CLOUDFLARE_API_TOKEN (CF_API_TOKEN is the depreciated version of this) should be set in your local environment so they’re exposed to wrangler.
  • Wrangler will try to read local environment variables from a .env file in the root of your repo (for instance, you can set CLOUDFLARE_ACCOUNT_ID like this)
  • The documentation for running Wrangler in CI/CD is at https://developers.cloudflare.com/workers/wrangler/ci-cd/. It’s admittedly quite bare, but it covers the main ground (setting the environment variable CLOUDFLARE_ACCOUNT_ID and specifying your account ID)
  • @gc-kismael As a specific point of help, when you create your API token at https://dash.cloudflare.com/profile/api-tokens there should be a curl command that’ll let you test whether the token works.
Read more comments on GitHub >

github_iconTop Results From Across the Web

`wrangler publish` returns error 10000 - Cloudflare Community
I create a simple wrangler worker project, and always fail to publish (or anything else) due to an auth 10000 error.
Read more >
How to fix authentication error code 10000 in cloudflare
There is problem, i keep encountering in cloudflare. It says - authentication error (code 10000) while logging to my cloudflare dashbord.
Read more >
Untitled
Post breinig stolberg, Urdu meaningful poetry, Doble de michael jackson, ... Kingdom hearts inner universe, Play store code error 961, Kalikalam movie songs ......
Read more >
@cloudflare/wrangler | Yarn - Package Manager
It's straightforward! Just run wrangler login , enter your credentials, and you're off to the races. ... When running wrangler dev as an...
Read more >
Untitled
Resolves: Bug 822700 - Bad DNs in ACIs can segfault ns-slapd - Resolves: Bug ... Bug 910996 - DS returns error 20 when...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found