API: Reset Password on Droplet fails with "Unable to authenticate you."

May 30, 2015 989 views

These commands create a droplet successfully

$ export TOKEN="faa02e8485a1536a8ff770a4db2bd6f690d5ea88da66blahbla"
$ curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d '{"name":"git","region":"nyc3","size":"512mb","image":"ubuntu-14-04-x64","ssh_keys":null,"backups":false,"ipv6":true,"user_data":null,"private_networking":null}' "https://api.digitalocean.com/v2/droplets" 

The returned droplet is (for example) number 5490611. We know then that $TOKEN is my correct API key. So then I try to reset the password:

curl -X POST -H 'Content-Type: application/json' -H 'Authorization: Bearer $TOKEN' -d '{"type":"password_reset"}' "https://api.digitalocean.com/v2/droplets/5490611/actions"

However, I get this error returned: {"id":"unauthorized","message":"Unable to authenticate you."}

Why is my password reset failing?

2 Answers

you are using single quotes in the second command, double quotes in the top command. the single quotes prevent the expansion of $VARIABLES.

I am getting same error and i am not using single quotes
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer 401dce8675a027ea0" "https://api.digitalocean.com/v2/droplets/1654916"

Have another answer? Share your knowledge.