Created
July 20, 2020 19:56
-
-
Save gene1wood/78427c80f48bc647199c2ab95f89f107 to your computer and use it in GitHub Desktop.
Small script to get users from CIS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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