Hello @alexanderbailey
Thank you for reaching out, and I am happy to help!
Well, that is a lengthy token! I’ve checked this, and the Global API Key should have no more than 37 chars.
Have you doublechecked the token in https://dash.cloudflare.com/profile/api-tokens
Thanks!
Thanks for responding, @vmarko.
I double-checked my Cloudflare account and re-confirmed that my global key is 52 characters, and then I created a second token just for W3TC and once again got a 53 character token.
So I went into Extension_CloudFlare_Api.php and changed
if ( 40 === strlen( $this->_key ) ) { // CF API Token.
to
if ( 53 === strlen( $this->_key ) ) { // CF API Token.
and I was able to authorize Cloudflare. My subsequent tests confirmed that as long as I keep my modification in W3TC’s code, the plugin can purge Cloudflare’s cache for me.
Obviously this is going to break if the plugin is updated and no longer accepts 53 character CF API tokens.
I’m also having this issue. My token is also 53 characters. I created mine dash.cloudflare.com/profile/api-tokens and used the WordPress template. Can you please advise when this will be resolved? I have also modified my plugin’s check and it works fine.
Hello @alexanderbailey @linuxpony
Thank you for your feedback.
Got it! Thank you for the clarification and sorry for the confusion.
Generaly for the Cloudflare extension, the API Key is used and not manually created token. Meaning the Global API key.
This being said, can you please just confirm that using the Token and updating the code, you were able to authorize Cloudflare and the purge is working as expected?
Thanks!
Hi @vmarko,
Versions 2.9.2 and 2.9.3 successfully authenticate with Cloudflare and successfully purge Cloudflare’s cache with my code modification in place.
I double-checked the installation on my live site just now by upgrading to 2.9.3 and testing the empty Cloudflare cache function (result: “Failed to purge Cloudflare cache: Improper API token / global key length”) and then I edited the code and retested and it worked (result: “Cloudflare cache successfully emptied.”).
FWIW, while I think the plugin code also needs to be fixed for General API Keys, my understanding is that it is preferable to create a use-specific API token in Cloudflare WordPress/W3TC (53 characters on both of my tests).
Thank you for your help!
W3TC responded to a bug report I sent and they say that it should be fixed in a future release.
Hello @alexanderbailey
Yes, I’ve replied to your email via the W3TC support channel.
Thank you for your feedback and your patience!