export IN_IP=`kubectl get svc -A | grep -m1 rke2-ingress-nginx-controller | sort | awk '{print $5}'`

CIAM_CLIENT_ID=$1
CIAM_CLIENT_SECRET=$2
EXT_TOKEN=$3

curl -kL -X POST https://$IN_IP/rest/v1/token \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --header "ClientId: $CIAM_CLIENT_ID" \
  --header "ClientSecret: $CIAM_CLIENT_SECRET" \
  --data "grant_type=urn:ietf:params:oauth:grant-type:token-exchange" \
  --data "subject_token=${EXT_TOKEN}" \
  --data "subject_token_type=urn:ietf:params:oauth:token-type:jwt" | jq '.'
