Created
April 30, 2019 06:48
-
-
Save geberl/fb1ea0391f3c4911c085e5ba5fee2f3f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python3 | |
# -*- coding: utf-8 -*- | |
import requests | |
def get_token(auth_url, image_name): | |
payload = { | |
'service': 'registry.docker.io', | |
'scope': 'repository:library/{image}:pull'.format(image=image_name) | |
} | |
r = requests.get(auth_url + '/token', params=payload) | |
if not r.status_code == 200: | |
print("Error status {}".format(r.status_code)) | |
raise Exception("Could not get auth token") | |
j = r.json() | |
return j['token'] | |
token = get_token('https://auth.docker.io', 'openjdk') | |
print(token) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment