Skip to content

Instantly share code, notes, and snippets.

@masatomix
Created April 2, 2019 12:53
Show Gist options
  • Save masatomix/52c117daf16b5a326c092ffca2eda399 to your computer and use it in GitHub Desktop.
Save masatomix/52c117daf16b5a326c092ffca2eda399 to your computer and use it in GitHub Desktop.
#!/bin/bash
clientId=xxx
clientSecret=xxx
login_hint=1001
user_code=675325
backchannelReq=`cat << EOS
curl http://localhost:8080/api/backchannel/authentication -X POST \
--user ${clientId}:${clientSecret} \
-d 'login_hint=${login_hint}' \
-d 'user_code=${user_code}' \
-d 'scope=openid' -s | jq .auth_req_id -r
EOS
`
auth_req_id=`eval "${backchannelReq}"`
echo ${auth_req_id}
for i in {0..3}; do
sleep 3
tokenReq=`cat << EOS
curl http://localhost:8080/api/token -X POST \
--user ${clientId}:${clientSecret} \
-H 'Content-type: application/x-www-form-urlencoded' \
-d 'auth_req_id=${auth_req_id}' \
-d 'grant_type=urn:openid:params:grant-type:ciba' -s
EOS
`
token=`eval "${tokenReq}"`
error=`echo ${token} | jq 'select(.error_description==null)'`
echo ${token} | jq
if [ -n "$error" ]; then
break;
# else
# echo ${token} | jq .error_description -r
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment