-
-
Save matiascarranza/8a4e9fcd73a4a6dd8bc60cc49ba4fe92 to your computer and use it in GitHub Desktop.
Auth0 Impersonate user API bash cURL script
This file contains hidden or 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
# Auth0 Impersonate | |
USER_ID_TO_IMPERSONATE="auth0|57dc84..." | |
ADMIN_USER_ID="auth0|572b9..." | |
CLIENT_ID="uoKEkF5..." | |
CLIENT_SECRET="aMgJisByYhrLkV5..." | |
BEARER="xovAuOGGBKeJh..." | |
URL=`curl --request POST \ | |
--url 'https://vidroll.auth0.com/users/'"$USER_ID_TO_IMPERSONATE"'/impersonate' \ | |
--header 'authorization: Bearer '$BEARER \ | |
--header 'content-type: application/json' \ | |
--data '{"protocol": "oauth2","impersonator_id": "'"$ADMIN_USER_ID"'","client_id": "'"$CLIENT_ID"'","additionalParameters":{"response_type": "code","state": ""}}'` | |
REDIRECT_URI=`curl -w "%{url_effective}\n" -I -L -s -S $URL -o /dev/null` | |
CODE=`echo $REDIRECT_URI | sed -n -e 's/^.*code=//p'` | |
curl --request POST \ | |
--url 'https://vidroll.auth0.com/users/oauth/token' \ | |
--header 'content-type: application/json' \ | |
--data '{"client_id": "'"$CLIENT_ID"'","client_secret": "'"$CLIENT_SECRET"'","code": "'"$CODE"'","grant_type": "authorization_code","redirect_uri": "http://localhost:3000/"}' | |
# RETURNS | |
# {"access_token":"wY0aZsj...","token_type":"Bearer"} |
This file contains hidden or 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
# Get Bearer token for impersonator API | |
GLOBAL_CLIENT_ID="2wtoDkd..." | |
GLOBAL_CLIENT_SECRET="OxuouN..." | |
curl "https://vidroll.auth0.com/oauth/token" --data 'client_id='"$GLOBAL_CLIENT_ID"'&client_secret='"$GLOBAL_CLIENT_SECRET"'&grant_type=client_credentials' | |
# RESPONSE | |
# {"access_token":"n7g3c5M7ZB...","token_type":"Bearer"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment