Skip to content

Commit 763e8ea

Browse files
committed
fix: implement authentication token retrieval for Docker Hub API
1 parent 3f40f9f commit 763e8ea

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

scripts/prune/registries/dockerhub.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,18 @@ def _get_auth_token(self) -> str:
3030
if self._auth_token:
3131
return self._auth_token
3232

33-
self._auth_token = self.password
33+
auth_data = {
34+
'identifier': self.username,
35+
'secret': self.password
36+
}
37+
38+
resp = requests.post(f'{self.DOCKER_HUB_API}/auth/token', json=auth_data)
39+
if resp.status_code != 200:
40+
sys.stderr.write(f'Docker Hub auth failed: {resp.status_code}\n')
41+
sys.stderr.write(f'{resp.text}\n')
42+
sys.exit(1)
43+
44+
self._auth_token = resp.json()['access_token']
3445
return self._auth_token
3546

3647
def list_versions(self) -> List[ImageVersion]:

0 commit comments

Comments
 (0)