Docker Community Forums

Share and learn in the Docker community.

How to obtain token for DTR API Access

dtr

(Calebboxboat) #1

I have accessed the DTR API Explorer through the web interface as described here: https://docs.docker.com/apidocs/overview/

All of the sample calls in the API Explorer use the Web API’s cookie to authenticate. How do I obtain a token to access the DTR API from outside the web environment programmatically?


(Fredgan) #2

Did you figure out how to do this? I need to do the same thing


(Patrick Devine) #3

Hey guys,

The easiest way is it use your token (you can find it in ~/.docker/config.json) and then use that for your password with basic auth. eg. curl -u <username>:<token> https://<dtr_host>/api/v0/repositories. In DTR 2.5 there’s a page per user which allows you to make other tokens.

I’ll check the docs and make sure this is explained.


(Fredgan) #4

I can’t find the file (~/.docker/config.json) but I figured out that since DTR is using basic auth, I can just supply the admin password in the command instead of the token.


(Patrick Devine) #5

You can do that, but it exposes your credentials which you may not want. If you’ve done a docker login that file should exist on Linux. I’m not 100% sure off the top of my head where it would exist if you’re using Docker for Mac/Windows though.