How test mode works
A client runs on a certificate, and every certificate is either a test or a production certificate. A client pointed at a test certificate:- talks to BankID’s test environment instead of production
- accepts only test BankIDs issued from demo.bankid.com
- can never authenticate a real person
The environment is a property of the certificate, not a flag you pass. There is no request that
can make a production client behave like a test one, or vice versa — which is exactly the
point.
1. Install the BankID test app
The production BankID app will not work against the test environment. You need the separate test build from BankID’s developer portal.2. Create a test BankID
Go to demo.bankid.com and issue a test BankID for any personnummer — for example199001011234. The number does not need to belong to a real person; the test CA will
issue for anything well-formed.
3. Run the flow
Point your integration at the same issuer as always:id_token back with your test identity’s name and personnummer.
What to test
The happy path
The happy path
Authorize → hosted page → BankID → redirect → token exchange → validated
id_token. Confirm
iss, aud and the signature all check out against JWKS.A returning user
A returning user
Log in twice with the same test BankID.
sub must be identical both times — that is your user
key, and your account lookup depends on it.Cancellation
Cancellation
Start a login and cancel in the app. You should land back on your
redirect_uri with an
error parameter, not hang.The abandoned browser
The abandoned browser
Complete BankID, then close the browser before it redirects. Your webhook (or a poll of the
session) should still report success — this is the most commonly missed case on mobile.
Expiry
Expiry
Open a login URL, wait, then let it sit. After 15 minutes it should show the invalid-link
screen rather than starting a fresh BankID.
Replay
Replay
Exchange the same authorization code twice. The second attempt must fail with
invalid_grant.Timings you will notice
These come from BankID and are the same in test and production:Going live
When you are ready, sajn switches your client to a production certificate. Nothing in your code changes — same issuer, same client id, same endpoints.Troubleshooting
The BankID app says the QR code is invalid
The BankID app says the QR code is invalid
You are almost certainly scanning with the production app against a test client. Use the test
app from the developer portal.
Your real BankID does not work
Your real BankID does not work
Correct, and intentional. A test client only accepts test BankIDs.
Nothing happens after scanning
Nothing happens after scanning
Check that your
redirect_uri is reachable from the device — localhost on a phone means the
phone, not your laptop. Use a tunnel or a deployed preview URL.
