I receive ā@{id=TOKEN2; status=active} True {} {@{code=10000; message=This API Token is validā
Giving me TOKEN from the user profile I generated and TOKEN2 from viewing my user tokens using the Bearer request.
I am now taking TOKEN and TOKEN2 that was just generated and attempting to purge the cache for a zone. I receive the error: {āsuccessā:false,āerrorsā:[{ācodeā:10000,āmessageā:āAuthentication errorā}]}
Is it possible there is a bug or something? Basically when I create a TOKEN, there is an example that says:
ā Test this token
To confirm your token is working correctly, copy and paste the below CURL command in a terminal shell to test.ā
It has the -H "Authorization: Bearer string inside of itā¦
I take that exact header and put it inside of my request, and it still fails with {āsuccessā:false,āerrorsā:[{ācodeā:10000,āmessageā:āAuthentication errorā}]}
Here is exactly what Iām sending
Invoke-RestMethod -URI āhttps://api.cloudflare.com/client/v4/zones/MY ZONE/purge_cacheā -Method āPOSTā -ContentType āapplication/jsonā -Headers @{āAuthorizationā=āTHE DATA FROM THE USER PROFILE PAGE I JUST CREATEDā} -Body ā{āfilesā:ā/testing/testā}ā
Which failsā¦ but if I send the example request using the exact same Authorization header - it works.
Invoke-RestMethod -URI āhttps://api.cloudflare.com/client/v4/user/tokens/verifyā -Method āGETā -ContentType āapplication/jsonā -Headers @{āAuthorizationā=āBearer THE DATA FROM THE USER PROFILE PAGE I JUST CREATEDā}
I am having the exact same issue with CURL through PHP and Powershell (examples given).
Here is example code in PHP using CURL. Set the $myzone variable to initiate a POST request an example purge of /testing/test/ which should throw some error or succeed
Thank you for helping! Do you have purge code that works on your end? Like I gave you my API key, could you test it or something? I donāt think thereās a way for me to contact Cloudflare. It should be so simple yet it seems broken lol.
Are you sure the X-Auth-Email and X-Auth-Key arenāt for the purge request? Neither work for me
Thank you! Thatās a good idea to maybe try a 3rd party service to see how it works.
It looks to me like your code uses the āGlobal APIā token, not to be confused with the āOrigin CAā token which are different from the token you can generate and then it also uses the email hader field. Say that 5 times fast.
zone: ${{ secrets.CLOUDFLARE_ZONE }}
# Using API Token
api_token: ${{ secrets.CLOUDFLARE_TOKEN }}
# Using Global Token
email: ${{ secrets.CLOUDFLARE_EMAIL }}
global_token: ${{ secrets.CLOUDFLARE_KEY }}
But thank you! I will try to take a look because I really need to get the purge going for Comments