Docker Hub API v2 token authentication issue -
currently, i'm working on light version of docker containers orchestrator , have able image digest public docker hub registry. want use docker registry api v2 purposes.
i'm trying authorization token using following api call:
curl https://auth.docker.io/token?service=index.docker.io&scope=repository:alpine:pull
... , response following:
{"token":"eyjhbgcioijfuzi1niisinr5cci6ikpxvcising1yyi6wyjnsuldthpdq0fku2dbd0lcqwdjqkfequtcz2dxagtqt1bruurbakjhtvvrd1fnwurwuvferxp0uk5gb3ppa2rytjbrnldgulfsrhbjvfrsuk9rovvwrmc2tmtgrlf6cfnuve5et2tgu01rttzumfkztnpwq1zrvkjpa2xhulvrnlexazftekflrncwee5qqtfnekv5txpvne5uzgfgdzb4tnpbmu16rxlnelu0tlrkyu1fwxhsrejdqmdovkjbtvrpmuv6uzfrnlfqskpnenbhujfot09qslhxrta2utbwwff6cfvnmhhpt2tvmlyxwtznbgsyvhpwwlfwbeppbghqvtbrnlzfuljtvg8wvwtwre1ga3dfd1lis29asxpqmenbuvljs29asxpqmerbuwneuwdbrvo0nkvlv3vksxhxothuuc9gweu3u3vyoxlkz3c3k2fkcndxeglxn004vhfua0n0dzbqzm1ss2vldexwaxntrfu4lzzsewz3qufwzwh6shdtwmxzr2dxt0jzaknccnpbt0jntlziuthcqwy4rujbtuncnef3rhdzrfzsmgxcqwd3qmdzrvzsmgxbrejfqmdovkhrnevquve3vvrotfzecenna2t6t2xwsfdfndznbgrzvfrwrfjwzerpbff6veu0nlnqwlhwam95v1raue9sbejxvws2v0u5vfjecfvsrkzkt2psu1nrtxdsz1levliwakjeohdqwue3vvrsyu16cehwemrkt2xovvvfutztrtawvvrwufzgullpalpculvnnlvrmhprenbcvwpkre9roudoemm2uwxarlfucepsa1zkt2towk5vc3ddz1ljs29asxpqmevbd0leu1fbd1jnswhbtzyxswlon1fuchntmffiyunwtdfztwnmmnzxzlnydlhhbhpsrdewn2nruefpruftzxduelnyrhplrgxqcdc4t1nstffzbnroywm5ehryyw0xu0kxy0zxq2tjpsjdfq.eyjhy2nlc3mioltdlcjhdwqioijpbmrlec5kb2nrzxiuaw8ilcjlehaioje0nzq1ndcyodmsimlhdci6mtq3ndu0njk4mywiaxnzijoiyxv0ac5kb2nrzxiuaw8ilcjqdgkioiizvtdcazf4dm9clva0mgjwvf9jsiisim5izii6mtq3ndu0njk4mywic3viijoiin0.516fs692wghni5sc44ib8ofslairrm6n1znvvo5kxaxlsxsp4re7vdmw5d0yqvtyekfzayii9yeptx4xjlq6da"}
it seems okay , i'm trying use obtained token next api call:
curl -i -h "authorization: bearer eyjhbgcioijfuzi1niisinr5cci6ikpxvcising1yyi6wyjnsuldthpdq0fku2dbd0lcqwdjqkfequtcz2dxagtqt1bruurbakjhtvvrd1fnwurwuvferxp0uk5gb3ppa2rytjbrnldgulfsrhbjvfrsuk9rovvwrmc2tmtgrlf6cfnuve5et2tgu01rttzumfkztnpwq1zrvkjpa2xhulvrnlexazftekflrncwee5qqtfnekv5txpvne5uzgfgdzb4tnpbmu16rxlnelu0tlrkyu1fwxhsrejdqmdovkjbtvrpmuv6uzfrnlfqskpnenbhujfot09qslhxrta2utbwwff6cfvnmhhpt2tvmlyxwtznbgsyvhpwwlfwbeppbghqvtbrnlzfuljtvg8wvwtwre1ga3dfd1lis29asxpqmenbuvljs29asxpqmerbuwneuwdbrvo0nkvlv3vksxhxothuuc9gweu3u3vyoxlkz3c3k2fkcndxeglxn004vhfua0n0dzbqzm1ss2vldexwaxntrfu4lzzsewz3qufwzwh6shdtwmxzr2dxt0jzaknccnpbt0jntlziuthcqwy4rujbtuncnef3rhdzrfzsmgxcqwd3qmdzrvzsmgxbrejfqmdovkhrnevquve3vvrotfzecenna2t6t2xwsfdfndznbgrzvfrwrfjwzerpbff6veu0nlnqwlhwam95v1raue9sbejxvws2v0u5vfjecfvsrkzkt2psu1nrtxdsz1levliwakjeohdqwue3vvrsyu16cehwemrkt2xovvvfutztrtawvvrwufzgullpalpculvnnlvrmhprenbcvwpkre9roudoemm2uwxarlfucepsa1zkt2towk5vc3ddz1ljs29asxpqmevbd0leu1fbd1jnswhbtzyxswlon1fuchntmffiyunwtdfztwnmmnzxzlnydlhhbhpsrdewn2nruefpruftzxduelnyrhplrgxqcdc4t1nstffzbnroywm5ehryyw0xu0kxy0zxq2tjpsjdfq.eyjhy2nlc3mioltdlcjhdwqioijpbmrlec5kb2nrzxiuaw8ilcjlehaioje0nzq1ndcyodmsimlhdci6mtq3ndu0njk4mywiaxnzijoiyxv0ac5kb2nrzxiuaw8ilcjqdgkioiizvtdcazf4dm9clva0mgjwvf9jsiisim5izii6mtq3ndu0njk4mywic3viijoiin0.516fs692wghni5sc44ib8ofslairrm6n1znvvo5kxaxlsxsp4re7vdmw5d0yqvtyekfzayii9yeptx4xjlq6da" https://index.docker.io/v2/alpine/manifests/latest
... , here i've got:
http/1.1 401 unauthorized content-type: application/json; charset=utf-8 docker-distribution-api-version: registry/2.0 www-authenticate: bearer realm="https://auth.docker.io/token",service="registry.docker.io",scope="repository:alpine:pull",error="invalid_token" date: thu, 22 sep 2016 12:27:54 gmt content-length: 138 strict-transport-security: max-age=31536000 {"errors":[{"code":"unauthorized","message":"authentication required","detail":[{"type":"repository","name":"alpine","action":"pull"}]}]}
does have ideas why token aouthentication fails such simple flow?
the response in www-authenticate
header trying tell need, although more helpful.
first thing: service
want registry.docker.io
.
second thing: repository name in scope
incomplete. official repositories have single-part name alpine
cli, in registry it's called library/alpine
.
so token request should be:
curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:library/alpine:pull"
and image request is:
curl --header "authorization: bearer eyjh..." https://index.docker.io/v2/library/alpine/manifests/latest
and you'll response.
Comments
Post a Comment