Connect Layer - Quickstart
Connect Layer provides a client-side functionality that allows you to authenticate user with their bank and retrieve accessCode
required to obtain user's permanent token.
Basic Setup
Connect Layer does not have any standalone files that need to be downloaded or installed, instead you simply need to include a short piece of regular JavaScript in your HTML that will load the Connect into your pages.
The following snippet of code will initialize basic version of the connect layer for the Sandbox environment and load authentication page for the user:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=1080px, initial-scale=1.0">
<title>DAPI</title>
</head>
<body>
<script src="https://cdn.dapi.com/connect/v3/connector.js"></script>
<script>
var handler = Dapi.create({
environment: Dapi.environments.sandbox, //either .sandbox or .production
appKey: 'your-app-key', //appKey you created on Dapi Dashboard
countries: ['AE'], //Alpha-2 format for country codes
isExperimental: false, //Recommended to keep this false, gives access to banks that are experimental / in beta
onSuccess: (d) => console.log(d), //Capture the success
onFailure: (e) => console.log(e), // Capture a failure
onReady: (r) => {
console.log("Ready!"),
handler.open() //open the widget
}
});
</script>
</body>
</html>
If authentication is completed successfully you will receive following parameters in the response:
Parameter | Type | Description |
---|---|---|
success | Boolean | Status of the authentication request |
accessCode | String | Single use, temporary access code that should be exchanged for user token |
connectionID | String | Connection identifier. Is needed to obtain Access Token. |
userSecret | String | Encrypted secret of the user. Is needed in majority of API requests |
userID | String | ID of the user. Is not needed in further API requests |
tokenID | String | Token identifier. Is not needed in further API requests |
Example of successful response:
{
"accessCode": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBLZXkiOiJiY2JmZjJhOGQ5MDk3MDJlYTY2YmM2ZGFlZWZlZjBlNTFiYWQ0OTFmODAzOWZkZTIzMzU3ZTc0ZDJkMDAwMjYyIiwiZXhwIjoxNjI4NDk5NjM3LCJpYXQiOjE2Mjg0OTkzMzcsImp0aSI6ImQ5YTlkNDE0LWVlODUtNDBkYS05NWMzLWRiZjRjNzI4M2RiZSIsIm90cCI6InpnU1d4dkFLcm5iNG1tS1JPZHRFWGhRTGZ3TjJ5WUpPSUN1U050NWMvTE09IiwidXVpZCI6IkJPTUxBRUFEOmVmZDM5ODlkLWNmYmEtNGFmYy1iZjBkLWY0ODk3ZGJmN2UyYiJ9.gFaPEfDjJvjYkI9nBxlupEy7Qxu860DGHNU7Wk86UHI",
"connectionID": "05322415-6d28-4271-9764-72576b0c90a1",
"operationID": "BOMLAEAD:b6bb89e8-347b-4a99-859b-bc01d721b5d9",
"status": "done",
"success": true,
"tokenID": "d9a9d414-ee85-40da-95c3-dbf4c7283dbe",
"userID": "fKlQCakNOXWRRbOGf0jCCHP/qArJP5VLH523+MbnfN+pDicRTPTT34ItzK7j1kunpte9njoDOhj/1v5723hM4g==",
"userSecret": "iVzJsDT0Yp0qzCub/pmp9ky4i47/9KjrB5NpUOvhS35SFmdOUcQjA7BFhdNQRVn/eTohF5/3pg7cBaWCEDerneSX6i99P0E61HImq+o0R0cp9u/wnxvY1vuj9AYiPdGUQV9N7aW1rYQBRwgSLzgO1HjKbiRxODAtWIFK32s6zC8yNG1MuQjkRBMsSNmJUmc3HKr91CPWUqBblGEqX1FaO7DdaogHvjJK5EqNvSq9BGWAuZsBHjmnk7VketKDR1wi37nHh7ZftT3/rxdSJPfPMStFQPhYlKYNlR+Hc9xRbBxgjaUvz0Yvywj8SBn+/FhnQLbhOfUajlp8LHT2HJ1anXuL1ILwV6Lk5i/bpEwuUeSwqjifKaCUeHcYv6VHKKN3iq61mtdKJYM/zrz8Z2dQDasKozf5ehBz22yhqEnecZSDg8RS2NLW7nPr76oPo+AlNLnQl8hJIg0p8UGVvdJUeV5gCZ2znhTS3aeFNg9ID7jivjVdIGJAjVwQtKT5KsH9c0gQJyQYGiYpojoox3op/WSFfEcPFo8wzMhsd5Dc3dfpmiW1hojn2DThoj0SHBiym1AiZeEiQHm7GQodP/J7d3jeY5P3m/W/G2EoHLEXZMKOQuM8l8fIFMKGhNvjvH5v1w3nXXp3Zcp3czCktfwREGfQ6DaK/37IJqiZzaTdDv4="
}
You will require accessCode
and connectionID
when calling Exchange Token in order to obtain a permanent accessToken
for the user. Or you will require the same values when calling an exchange token function in any of the Server Side Libraries .
userSecret
value will be required as a parameter in all of the following Data and Payment API calls.
Complete set-up example
The Connect Layer cannot be directly opened as an HTML file from your computer's file system.
Instead, the HTML file needs to be served. Below is an example of how to do it using Node.js when wanting to test the Connect Layer locally.
var express = require('express')
var cors = require('cors')
var path = require('path')
const app = express();
const port = 8000; // default port to listen
app.use(cors())
app.get("/", (req, res) => {
res.sendFile(path.resolve('./main.html')); //the path you need to take from this file to your html file that includes the connect layer handler
});
app.listen(port, () => {
console.log(`server started at http://localhost:${port}`);
});
Updated 10 months ago