I feel like I'm going mental. JWTs are not allowing access despite me following every doc
So I am running a dockerised application with cloudflared + tunnel + access to host this appliction to https://myapp.mywebsite.com
I got everything up and running and it worked - I could access this page fine.
I've then been trying to use Zero Trust with service tokens to access programatically. I've followed the docs here: https://developers.cloudflare.com/cloudflare-one/identity/service-tokens/
I send my first request
However, I then try and send subsequent requests and am constantly encountering 401 not authorised errors.
I have tried the following:
Every single try is met with a 401 unauthorized.
I've checked my JWT on jwt.io and all fields are expected.
I've regularly been checking access using the
In my Zero Trust -> Access -> Applications -> Policies I have the following set up:
I got everything up and running and it worked - I could access this page fine.
I've then been trying to use Zero Trust with service tokens to access programatically. I've followed the docs here: https://developers.cloudflare.com/cloudflare-one/identity/service-tokens/
I send my first request
curl -H "CF-Access-Client-Id: <CLIENT_ID>" -H "CF-Access-Client-Secret: <CLIENT_SECRET>" https://app.example.com and access the page fine so I know it is working.However, I then try and send subsequent requests and am constantly encountering 401 not authorised errors.
I have tried the following:
curl -H "cookie: CF_Authorization=<CF_AUTHORIZATION_COOKIE>" https://myapp.mywebsite.comcurl -H "cf-access-token=<CF_AUTHORIZATION_COOKIE>" https://myapp.mywebsite.comcurl --cookie "CF_Authorization=<CF_AUTHORIZATION_COOKIE>" https://myapp.mywebsite.com
<CF_AUTHORIZATION_COOKIE> being just the JWT string or mimicking the exact contents of the set-cookie response.Every single try is met with a 401 unauthorized.
I've checked my JWT on jwt.io and all fields are expected.
I've regularly been checking access using the
CLIENT_ID and CLIENT_SECRET and it always works.In my Zero Trust -> Access -> Applications -> Policies I have the following set up:
- Service token. Action = SERVICE AUTH
- JWT. Action = ALLOW. Include Selectors "Service Token" with value
my-only-service-tokenand "Any Access Service Token" with value "Any non expired Service Token will be matched".


