Integrating with the ING’s PSD2 sandbox 💻

Lucian Roșu
ING Blog
Published in
3 min readJul 2, 2020
PSD2 (Payment Services Directive 2)

Have you heard of PSD2?

The Revised Payment Services Directive (PSD2) is an European legislation that allows bank customers to let third-parties have access to their finances in a secure way.

Thanks to PDS2, in the near future, you might use Google, Facebook, Apple, or perhaps a fintech startup to pay your bills, analyze your spending, create a budget, or transfer money, while still having your money in your current bank account.

ING is fully compliant with the PSD2 regulations and a developer portal with all the information you need is available at ING’s Developer Portal: https://developer.ing.com/.

Nevertheless, if you navigate through the documentation you might get a bit confused. All the showcases/examples are presented by using ‘cURL’ commands and if you specifically search for an available Software Development Kit (SDK) you won’t be able to find anything.

So, I tried my luck. I started to work on an SDK written in Java and, by understanding the examples from the developer portal, I created a small library that will make your life easier when integrating with the sandbox API environment of ING.

What is the sandbox environment? It is a test environment, a playground, where you can test if your authentication and authorization flows are working as expected. You can also call some showcase APIs and get some actual data as well! But, to better quote the documentation:

“The sandbox contains a simulator that simulates API responses.”

Let’s do some requests!

The prerequisites for the next examples are: Java 1.8 and Maven.

Start by cloning the following GitHub repository: https://github.com/danlucian/ing-psd2-oauth2-sdk

After cloning the repository, run the following command in your terminal so you can have access to the library as a Maven dependency (served directly from your local .m2 repository). Note: the library is not published on a public maven repository yet:

Then, you can load the library as a dependency in your project:

· If you are using Maven:

· If you are using Gradle:

Let’s integrate the SDK in your application:

  1. Create a ClientSecrets instance and load your certificates:

Client secrets consist of two pairs of a certificate and a private key: X509Certificate and RSAPrivateKey. One pair is for the client and the second is for signing the payloads of the requests to the APIs.

The constructor for the ClientSecrets class is overloaded and it will accept pairs of: byte arrays, Files, or X509Certificate/RSAPrivateKey directly.

2. Define your desired scopes (if you don’t have any scope, go directly to step 7):

Because ING implemented the OAuth2 specifications, you need to define your desired scopes.

3. Instantiate a sandbox flow:

After defining your client secrets and your desired scopes you can instantiate a flow. A flow will help you get an access-token, a preflight-url and a customer-token in a concise and easy way.

4. Get an application access token:

5. Get a preflight (granting) url:

6. Get a customer access token:

7. Get an application access token only, without having to define one or more scopes:

And that was it! At this moment you have received an application token or a customer access token that can be used as Bearer in your requests to ING’s sandbox APIs.

--

--

Lucian Roșu
ING Blog

Let's talk about distributed systems and security.