Blog TIL Now Tags Projects About

This shows how to use form posts… and it is a good example of how to call Azure AD (or a similar OAuth endpoint) to get a Bearer Token (given a Client ID and Client Secret).

#!/usr/bin/env bash
identity_url="https://your-identity-endpoint.example.com"
scope="https://your-scope/.default"
client_id="YOUR_CLIENT_ID"
client_secret="YOUR_CLIENT_SECRET"
xh "${identity_url}/oauth2/v2.0/token" -f scope=$scope -f client_id=$client_id -f client_secret=$client_secret |
jq -r .access_token

Then this is what it looks like to use that bearer token (see the -A bearer and -a $bearer parameters).

#!/usr/bin/env bash
api_url="http://localhost:61020"
tenant_id="YOUR_TENANT_ID"
environment="TEST01"
setting_name="TestCustomScopes"
bearer="TOKEN_FROM_ABOVE"
xh $api_url/$tenant_id/v1/settings/$environment/$setting_name -A bearer -a $bearer