This script obtains/deletes/validates Sbanken API key using a headaless programmatic web browser with Playwright.
Please read through the code as blindly trusting it would be stupid! It will log into your Sbanken account and you should ensure that there is not funny business being done!
Note that this code will log in with "BankID with app", so "BankID on mobile" is not yet implemented. Feel free to make a PR!
- Ensure that you've enrolled in the Beta-program to access the API service.
- Ensure that you've installed the browser binaries.
- Run
npm install
- Copy file
.env.example
to.env
and fill in values - Ready to go!
npm run create
Creates a new API-key.
npm run clear-all
Deletes all existing API-keys.
npm run validate [api-key]
Validate the API-key.
To see what's going on you can set BROWSER_HEADLESS
to false
to make Playwright display the Chromium with a GUI.
Idk, I wanted to see if it was possible to do a programmatic login that would handle BankID. I also wanted an automattic renewal of my Sbanken API tokens since I'm lazy...