Docker Community Forums

Share and learn in the Docker community.

401 unauthorized with insufficient_scope for a PUT rest api call

dockerhub
docker

(Sydney) #1

Hi all,

I’m trying to make a PUT rest api call by after getting token from auth.docker.io/token.

However, I’m still getting 401 even provided the token.

The call worked well when I made it to my private registry.
Also, I tried generating token and getting tag list by calling GET v2/{repostioryname}/tags/list. That works just fine.

However, the call still failed at the API call to PUT v2/{repositoryname}/manifests/{newtagname}

I’ve attached the correct manifest.json file to this call.

Does anyone know what’s wrong with this?

Request:
PUT /v2/upscontent/nanoserver/manifests/alpine2 HTTP/1.1
Host: registry-1.docker.io
Content-Type: application/vnd.docker.distribution.manifest.v2+json
Authorization: Bearer eyJhbG…(It’s too long)
Cache-Control: no-cache
Postman-Token: 68f91bbb-347a-1f39-e467-73db614a7581

{
“schemaVersion”: 2,
“mediaType”: “application/vnd.docker.distribution.manifest.v2+json”,
“config”: {
“mediaType”: “application/vnd.docker.container.image.v1+json”,
“size”: 1511,
“digest”: “sha256:e21c333399e0aeedfd70e8827c9fba3f8e9b170ef8a48a29945eb7702bf6aa5f”
},
“layers”: [
{
“mediaType”: “application/vnd.docker.image.rootfs.diff.tar.gzip”,
“size”: 2064911,
“digest”: “sha256:2fdfe1cd78c20d05774f0919be19bc1a3e4729bce219968e4188e7e0f1af679d”
}
]
}

Response:
Content-Length →244
Content-Type →application/json; charset=utf-8
Date →Tue, 19 Dec 2017 02:28:47 GMT
Docker-Distribution-Api-Version →registry/2.0
Strict-Transport-Security →max-age=31536000
Www-Authenticate →Bearer realm=“https://auth.docker.io/token",service=“registry.docker.io”,scope="repository:upscontent/nanoserver:pull,push”,error=“insufficient_scope”