Files
sailing-analytics/docker/obtainToken.sh
T

20 lines
679 B
Bash
Executable File

#!/bin/bash
# Based on kizbitz/dockerhub-v2-api-organization.sh at https://gist.github.com/kizbitz/175be06d0fbbb39bc9bfa6c0cb0d4721
# Example for the Docker Hub V2 API
# Returns all images and tags associated with a Docker Hub organization account.
# Requires 'jq': https://stedolan.github.io/jq/
TOKEN_FILE=~/.docker/.token
# set username, password, and organization
read -p "Username: " UNAME
read -s -p "Password: " UPASS
echo
# get token
echo "Retrieving token ..."
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${UNAME}'", "password": "'${UPASS}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
echo "$TOKEN" >"${TOKEN_FILE}"