Skip to content

Instantly share code, notes, and snippets.

@gene1wood
Created July 20, 2020 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gene1wood/78427c80f48bc647199c2ab95f89f107 to your computer and use it in GitHub Desktop.
Save gene1wood/78427c80f48bc647199c2ab95f89f107 to your computer and use it in GitHub Desktop.
Small script to get users from CIS
export person_api_client_id=xxx
export person_api_client_secret=xxx
if [ -z "$person_api_bearer_token" ]; then
echo "Fetching bearer token"
export person_api_bearer_token=$(curl --silent --request POST --url https://auth.mozilla.auth0.com/oauth/token --header "Content-Type: application/json" --data "{\"client_id\":\"${person_api_client_id}\",\"client_secret\":\"${person_api_client_secret}\",\"audience\":\"api.sso.mozilla.com\",\"grant_type\":\"client_credentials\"}" | jq -r '.access_token')
fi
function url_quote {
echo $1 | python3 -c "import urllib.parse; print(urllib.parse.quote(input()))"
}
function get_auth0_user {
curl --silent -H "Authorization: Bearer ${person_api_bearer_token}" "https://person.api.sso.mozilla.com/v2/user/user_id/$(url_quote "$1")" | python3 -m json.tool
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment