Docker Community Forums

Share and learn in the Docker community.

Difficulty using Docker HTTP Token Authentication

(Blakeborgna) #1

Hi Docker Community

I am having trouble listing the tags in a repository from the command line. The repository is private so I have to authenticate and to do this I have been following the process described in the docs at to obtain an authentication token.

I first send a GET request for the tags of the private repo and then I use the service and scope given in the WWW-Authenticate response header to request an authentication token. I then repeat the original GET request and include the received token as a bearer token in the authentication header. When I first started working on this a few weeks ago, this process worked correctly and the tags that I requested were sent back. I then tried to do the same thing the next day and I could no longer get the tags with this process. Since then I have tried again periodically and it still isn’t working for me.

What is happening now is that when I send the first unauthorised request to the private repo, I get a 404 response instead of the 401 that the docs say I should get back.

Below are the commands that I’m using to get my basic auth, token and the final request to get the tags. I don’t know why I’m not getting the responses that the docs say I should be getting and I can’t work out how to make this authentication process work. Any help would be greatly appreciated.

DOCKER_KEY=$(cat ~/.docker/config.json | jq '.auths[""].auth')

TOKEN=$(curl -X GET${REPO}:pull -H "Authorization: Basic ${DOCKER_KEY}") | jq -r .token

curl -s -X GET${REPO}/tags/ -H "Authorization: Bearer ${TOKEN}"