hashicorp / go-discover

Discover nodes in cloud environments
Mozilla Public License 2.0
563 stars 123 forks source link

Digitalocean: Unable to authenticate you #60

Closed webchi closed 5 years ago

webchi commented 6 years ago

Hello. I have such config to init auto join in consul 1.2.3, 1.3.0

"retry_join": ["provider=digitalocean region=fra1 tag_name=cnslmaster api_token=my-token-here]"],

But on consul agent I have errors

    2018/10/23 07:49:48 [WARN] agent: Join LAN failed: No servers to join, retrying in 30s
    2018/10/23 07:49:59 [ERR] agent: Coordinate update error: No cluster leader
    2018/10/23 07:50:18 [ERR] agent: Join LAN: discover-digitalocean: GET https://api.digitalocean.com/v2/droplets?page=1&per_page=200&tag_name=cnslmaster: 401 Unable to authenticate you.

Checked API answer with curl and it works

curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer my-token-here" "https://api.digitalocean.com/v2/droplets?page=1&per_page=1"
...
Response here

Is it possible to fix?

UPD CLI is working

discover addrs provider=digitalocean region=fra1 api_token=my-token-here
Registered providers: [aliyun aws azure digitalocean gce os packet scaleway softlayer triton vsphere]
[DEBUG] discover: Using provider "digitalocean"
[DEBUG] discover-digitalocean: Using region=fra1 tag_name=
[INFO] discover-digitalocean: Found instance consul-serv1 (116188472)
[INFO] discover-digitalocean: Found instance consul-serv2 (116188611) 
[INFO] discover-digitalocean: Found instance consul-serv3 (116188612)