Sample code for 30+ languages & platforms
Classic ASP

ABN AMRO OAuth2 Client Credentials Authentication

See more ABN AMRO Examples

Demonstrates how to obtain an access token for an ABN AMRO online API using OAuth2 with the Client Credentials flow.

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

' This example requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.

' This example sends the following CURL request:

' 	curl -X POST -k https://auth-sandbox.connect.abnamro.com:8443/as/token.oauth2 \
' 	-v \
' 	--cert TPPCertificate.crt \
' 	--key TPPprivateKey.key \
' 	-H 'Cache-Control: no-cache' \
' 	-H 'Content-Type: application/x-www-form-urlencoded' \
' 	-d 'grant_type=client_credentials&client_id=TPP_test&scope=psd2:payment:sepa:write psd2:payment:sepa:read'

set cert = Server.CreateObject("Chilkat.Cert")
success = cert.LoadFromFile("qa_data/certs/TPPCertificate.cer")
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( cert.LastErrorText) & "</pre>"
    Response.End
End If

set bdKey = Server.CreateObject("Chilkat.BinData")
success = bdKey.LoadFile("qa_data/certs/TPPprivateKey.key")

set privKey = Server.CreateObject("Chilkat.PrivateKey")
success = privKey.LoadAnyFormat(bdKey,"passwordIfNeeded")
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( privKey.LastErrorText) & "</pre>"
    Response.End
End If

success = cert.SetPrivateKey(privKey)
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( cert.LastErrorText) & "</pre>"
    Response.End
End If

set http = Server.CreateObject("Chilkat.Http")

success = http.SetSslClientCert(cert)
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( http.LastErrorText) & "</pre>"
    Response.End
End If

set req = Server.CreateObject("Chilkat.HttpRequest")
req.AddParam "grant_type","client_credentials"
req.AddParam "client_id","TPP_test"
req.AddParam "scope","psd2:payment:sepa:write psd2:payment:sepa:read"

req.HttpVerb = "POST"
req.ContentType = "application/x-www-form-urlencoded"

set resp = Server.CreateObject("Chilkat.HttpResponse")
success = http.HttpReq("https://auth-sandbox.connect.abnamro.com:8443/as/token.oauth2",req,resp)
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( http.LastErrorText) & "</pre>"
    Response.End
End If

If (resp.StatusCode <> 200) Then
    Response.Write "<pre>" & Server.HTMLEncode( resp.BodyStr) & "</pre>"
    Response.End
End If

' Get the JSON result:
' {"access_token":"TIhycwl8rfrZPkXGw15mwldASAAK","token_type":"Bearer","expires_in":7200}
set json = Server.CreateObject("Chilkat.JsonObject")
success = json.Load(resp.BodyStr)
Response.Write "<pre>" & Server.HTMLEncode( "access_token: " & json.StringOf("access_token")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "token_type: " & json.StringOf("token_type")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "expires_in: " & json.StringOf("expires_in")) & "</pre>"

%>
</body>
</html>