"invalid credentials: API Token must not be empty"
elbasan opened this issue · 2 comments
Not sure why it is happening, I tried it with and without quotes but am always getting an error that I haven't provided the API token, which I did.
latest: Pulling from jetrails/drone-cloudflare-caching
Status: Downloaded newer image for jetrails/drone-cloudflare-caching:latest
error: invalid credentials: API Token must not be empty
I would be glad to help you figure this out. Based on how you worded the problem, I am making the assumption that you are inputting the value of the token directly into settings.api_token.from_secret. If you want to use the token directly in the config file (not recommended), then it should look something like:
...
settings:
api_token: <CLOUDFLARE_API_TOKEN>
zone_identifier: <CLOUDFLARE_ZONE_ID>
...But again, that is not recommended since you would be committing sensitive information into your repo. Drone uses from_secret to get the value of a secret based on the passed secret's name (this can be a drone, vault, k8s, or aws secret). So the format when using a secret should look like this (which you are doing):
...
settings:
api_token:
from_secret: <SECRET_NAME_THAT_HOLDS_VALUE_FOR_TOKEN>
zone_identifier:
from_secret: <SECRET_NAME_THAT_HOLDS_VALUE_FOR_ZONE>
...More information about secrets can be found here.
The error itself is coming directly from Cloudflare. You can see where it is coming from if you look at src/main.go#L28. If you suspect that there might be something wrong with the docker image and not your drone configuration, we can always test it with the following command:
docker run --rm \
-e PLUGIN_API_TOKEN="<CLOUDFLARE_API_TOKEN>" \
-e PLUGIN_ZONE_IDENTIFIER="<CLOUDFLARE_ZONE_ID>" \
-e PLUGIN_ACTION="purge_everything" \
jetrails/drone-cloudflare-cachingMy hunch is that the values are just not being passed correctly to the image. The above was based on a big assumption I made about how you are doing things. If I am incorrect, please let me know and I can help you further debug this issue 😃.
I'm such an idiot, thanks a lot I put the key in the repository secret in our drone frontend and it worked!
