Created
June 12, 2018 14:02
-
-
Save alexkappa/255b029d39694904d31ba9ac6b182265 to your computer and use it in GitHub Desktop.
Auth0 clean-up script
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
#!/usr/bin/env bash | |
AUTH0_DOMAIN=<your-auth0-domain> | |
AUTH0_TOKEN=<your-auth0-token> | |
function client_list() { | |
curl -sS \ | |
-H "Authorization: Bearer $AUTH0_TOKEN" \ | |
"https://$AUTH0_DOMAIN/api/v2/clients?fields=client_id,name&include_fields=true&_=$(date +%s)" |\ | |
jq -r -c -M '.[]' | |
} | |
function client_delete() { | |
local client_id=$1 | |
curl -sS \ | |
-X DELETE \ | |
-H "Authorization: Bearer $AUTH0_TOKEN" \ | |
"https://$AUTH0_DOMAIN/api/v2/clients/$client_id" | |
} | |
function main() { | |
while read -r client; do | |
client_id=$(echo $client | jq -r '.client_id') | |
client_name=$(echo $client | jq -r '.name') | |
if [[ $client_name = *"Test"* ]]; then | |
echo "deleting: $client" | |
client_delete $client_id | |
fi | |
done <<< "$(client_list)" | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment