Question

"Can't authenticate you" error when trying to run a DigitalOcean API command

I tried to run this command for rebuilding my droplet:

curl -X POST "https://api.digitalocean.com/v2/droplets/MY_DROPLET_ID/actions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer MY_API_TOKEN" \
-d '{"type":"rebuild","image":"ubuntu-16-04-x64"}' 

Note I used MY_DROPLET_ID, taken from my cloud.digitalocean.com/droplets. Note I used MY_API_TOKEN (read and write), taken from cloud.digitalocean.com/settings/api/tokens.

I’d like to know what’s bad with my command? I might missed something aside of droplet-ID and API-token.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Javier from the DO support team helped me with this. I’ll now quote his response:

I appreciate you contacting us with this issue. Sorry to hear about this case. Currently, the “Can’t authenticate you” error specifically is with the failure to accept the token being passed in.

The format is correct here, so the only thing I can think of is either the key is missing or something has caused the key to be expired.

Indeed, like Javier said, the problem was with the API token. I created a new token and then the operation succeeded.

I also experienced the same issue but resolved it by regenerating a new API token and then echo token-key in my local machine from any location. Voila!!!

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.