Quickstart
This guide takes you through your first BankID (SE) authentication against the staging environment, using curl in a
terminal. The other eIDs work the same way: start a flow, bring the user to their eID, and fetch the result.
Before you start
- Staging API keys: an
accountIdand asecretKey. Ask support@idkollen.se if you don't have them. - A test BankID on your phone or computer. See Testing.
In the commands below, replace ACCOUNT_ID and SECRET_KEY with your keys.
1. Start an authentication
curl -u ACCOUNT_ID:SECRET_KEY https://stgapi.idkollen.se/v3/bankid-se/auth \
-H 'Content-Type: application/json' \
-d '{}'
{
"id": "1668b9da-bff1-4dfc-ad48-60507b5a8d12",
"status": "PENDING",
"autoStartToken": "6e8fdb9e-4cc7-42a7-9ce7-59947aeec6e6",
"qrStartToken": "8b9c387f-8948-4b53-b6a5-519eee985d44",
"qrStartSecret": "f47d75e0-6662-4bb9-9b09-ca37849ef1e0",
"hintCode": null
}
The flow is now PENDING, waiting for the user. Note the id and the autoStartToken.
2. Open BankID
On the device that has your test BankID, open this link, with your autoStartToken in it:
https://app.bankid.com/?autostarttoken=AUTO_START_TOKEN&redirect=null
Identify yourself in the BankID app.
In your own application you would show a QR code or open the app for the user. See Showing BankID to the user.
3. Fetch the result
Fetch the flow with its id:
curl -u ACCOUNT_ID:SECRET_KEY https://stgapi.idkollen.se/v3/bankid-se/auth/ID
While you are still in the app, the status is PENDING. Your application would repeat this about once a second.
When you have identified yourself, the result is COMPLETED with your test identity:
{
"id": "1668b9da-bff1-4dfc-ad48-60507b5a8d12",
"status": "COMPLETED",
"ssn": "YYYYMMDDXXXX",
"name": "Firstname Lastname",
"givenName": "Firstname",
"surname": "Lastname",
"authenticatedAt": "2024-01-15T13:37:00Z"
}
If you cancel in the app or wait too long, the result is FAILED with an error such as CANCELLED or
SESSION_TIMEOUT.
To cancel a pending flow yourself:
curl -u ACCOUNT_ID:SECRET_KEY -X DELETE https://stgapi.idkollen.se/v3/bankid-se/auth/ID
4. Move it into your code
The SDKs do the same in a few lines, including the polling. In TypeScript:
import { IdentisureClientBuilder } from "@identisure/client";
const client = new IdentisureClientBuilder(process.env.ACCOUNT_ID!, process.env.SECRET_KEY!)
.environment("staging")
.build();
const started = await client.bankidSe().auth({});
// Show a QR code or open the BankID app for the user here
const result = await client.bankidSe().waitForAuth(started.id);
if (result.status === "COMPLETED") {
console.log(`Hello ${result.name}`);
}
Next steps
- Concepts: how flows, statuses and credentials work.
- The introduction page of your eID, for example BankID (SE), to choose the right flow.
- Callbacks, if you want results pushed to your server.
- Going live, before you switch to the live environment.