Last active
April 3, 2019 19:01
-
-
Save jackinf/845b23ae699ac3e9393ddf43c25db53a to your computer and use it in GitHub Desktop.
ING sandbox script
This file contains 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
#!/bin/bash | |
# Generate the signature | |
export LANG=en_US | |
payload="grant_type=client_credentials" | |
payloadDigest=`echo -n "$payload" | openssl dgst -binary -sha256 | openssl base64` | |
digest=SHA-256=$payloadDigest | |
reqDate=$(LC_TIME=en_US.UTF-8 date -u "+%a, %d %b %Y %H:%M:%S GMT") | |
reqId=`uuidgen` | |
httpMethod=post | |
reqPath="/oauth2/token" | |
signingString="(request-target): $httpMethod $reqPath | |
date: $reqDate | |
digest: $digest | |
x-ing-reqid: $reqId" | |
signature=`printf "$signingString" | openssl dgst -sha256 -sign ~/sandboxcerts/example_client_signing.key -passin "pass:changeit" | openssl base64 -A` | |
# Request an access token | |
curl -i -X POST "https://api.sandbox.ing.com"$reqPath \ | |
-H 'Accept: application/json' \ | |
-H 'Content-Type: application/x-www-form-urlencoded' \ | |
-H "Digest: ${digest}" \ | |
-H "Date: ${reqDate}" \ | |
-H "X-ING-ReqID: ${reqId}" \ | |
-H "authorization: Signature keyId=\"e77d776b-90af-4684-bebc-521e5b2614dd\",algorithm=\"rsa-sha256\",headers=\"(request-target) date digest x-ing-reqid\",signature=\"$signature\"" \ | |
-d "${payload}" \ | |
--cert ~/sandboxcerts/example_client_tls.cer \ | |
--key ~/sandboxcerts/example_client_tls.key |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment