获取Bearer令牌后无法发出获取请求-401错误“范围不足”

时间:2018-06-20 07:45:20

标签: oauth bearer-token dockerhub docker-api

我有以下请求从Docker Hub API获取承载令牌,然后将该令牌用于对给定端点的GET请求:

select * from yourtable where bag1 < bag2 and bag1 < bag3

如果我运行该命令,则会出现此错误:

#!/usr/bin/env bash

raw_token="$(curl https://auth.docker.io/token?service=registry.docker.io&scope=repository:library/ubuntu:list)";
token="$(node -pe "JSON.parse('$raw_token').token")"
curl -i -H "Authorization: Bearer $token" https://registry-1.docker.io/v2/library/ubuntu/tags/list

有人知道我如何提出正确的请求并获得正确的令牌吗?

1 个答案:

答案 0 :(得分:1)

获得令牌时,可以指定scope = repository:library / ubuntu:list。使用令牌时,它表示您需要scope =“ repository:library / ubuntu:pull”。