Skip to content

Instantly share code, notes, and snippets.

@lapinek
Last active September 4, 2018 18:09
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 lapinek/7fc688918c51070d2c6a7ab2dc22a9c7 to your computer and use it in GitHub Desktop.
Save lapinek/7fc688918c51070d2c6a7ab2dc22a9c7 to your computer and use it in GitHub Desktop.
AM 6.0 OAuth 2.0 public "pkce" client requesting access token with cURL
authz_code=$(curl -s -w "%{redirect_url}" 'http://am-service.sample.svc.cluster.local/openam/oauth2/authorize?response_type=code&client_id=pkce&redirect_uri=http://localhost:9999&scope=openid&code_challenge=code_verifier' \
-H 'Cookie: iPlanetDirectoryPro='$(curl -s 'http://am-service.sample.svc.cluster.local/openam/json/realms/root/authenticate' \
-X POST \
-H 'X-OpenAM-Username:amadmin' \
-H 'X-OpenAM-Password:password' \
| sed -e 's/^.*"tokenId":"\([^"]*\)".*$/\1/') \
| sed 's/^.*?code=\([^&]*\).*$/\1/') \
&& curl 'http://am-service.sample.svc.cluster.local:80/openam/oauth2/access_token' \
-X POST \
--data 'client_id=pkce&redirect_uri=http://localhost:9999&grant_type=authorization_code&code='$authz_code \
-H 'Content-Type: application/x-www-form-urlencoded'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment