Adding Credentials for VAT API Access
To request a new VAT API access request, please visit dccscr and create a new issue with the "VAT Client Read API Access" template.
Here is an example script to help apply your credentials for read access to the VAT API.
#!/bin/bash
set -e -o pipefail
default_client_id="my_client_id"
function usage() {
cat <<EOF
$0 <vat_api_url> [<client_secret>] [<client_id>]
- client_secret is retrieved from the keycloak client you are using to query the VAT API. Provided as the second argument.
- client_id is the name of the client you are using to query the VAT API. Defaults to "$default_client_id" or is provided as the third argument.
EOF
exit 1
}
if [ $# -lt 2 ]; then
usage
fi
url=$1
client_secret=$2
client_id=${3:-"$default_client_id"}
sa_token=$(
curl \
--silent \
--url 'https://login.dso.mil/auth/realms/baby-yoda/protocol/openid-connect/token' \
--header 'content-type: application/x-www-form-urlencoded' \
--data grant_type=client_credentials \
--data client_id="$client_id" \
--data client_secret="$client_secret" | jq .access_token -r
)
curl --oauth2-bearer "$sa_token" "$1"