đ BUG: Wrangler publish returning generic error: Authentication error [code: 10000]
See original GitHub issueWhat 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:
- Created a year ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
[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)Iâm closing this issue as it seems the root issue is resolved. To tie together some of the notes from the thread though:
[vars]
section inwrangler.toml
is for variables that will be exposed to your worker. Environment variables likeCLOUDFLARE_API_TOKEN
(CF_API_TOKEN
is the depreciated version of this) should be set in your local environment so theyâre exposed to wrangler..env
file in the root of your repo (for instance, you can setCLOUDFLARE_ACCOUNT_ID
like this)CLOUDFLARE_ACCOUNT_ID
and specifying your account ID)curl
command thatâll let you test whether the token works.