In the CircleCI documentation, for API v2, the examples given show to use just the “Authorization” header to authenticate. But this doesn’t work.
For example, in listing checkout keys (CircleCI API), it says that this command should work:
curl --request GET \
--url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/checkout-key \
--header 'authorization: Basic REPLACE_BASIC_AUTH'
But in fact what you get back is:
{
"message" : "Project not found"
}
You actually have to pass the old v1 API’s “Circle-Token” header, and then your request works:
curl -H "Circle-Token: your-token-here" https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/checkout-key
{
"next_page_token" : null,
"items" : [ {
"type" : "deploy-key",
"preferred" : true,
"created_at" : "2019-07-25T23:48:32.315Z",
"public_key" : "ssh-rsa AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA \n",
"fingerprint" : "00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff"
} ]
}
Tested using BitBucket with private repositories.