Adapted from https://github.com/Jenji/auth0-curl
A simple curl wrapper that calls Auth0 (more specifically /oauth/ro
), retrieves a JWT and sticks the correct
Authorization header for you. Any argument is passed to curl, see the source.
- Edit the script and replace the 4 environment variables (
AUTH0_DOMAIN
,AUTH0_CLIENTID
,AUTH0_USERNAME
,AUTH0_PASSWORD
) with your Auth0 setup - Install jq, a very nice JSON parser
Exactly like you would use curl, no restrictions.
curl-auth0 -vvv -X GET 'http:https://localhost:8080/my-api'
Behind the scenes, this will do:
- a call to Auth0
/oauth/ro
- get the result (a JWT) that looks like this:
{"id_token":"xxx.yyy.zzz","access_token":"aaaaaaaaaaaaaaaa","token_type":"bearer"}
- extract the
id_token
from the JWT - call curl with the args you supplied to
curl-auth0
, and add theAuthorization: Bearer ${id_token}
header