The demo lets you optionally pin-point a person for authentication. The autoStartToken is an optional startup parameter for the Swedish BankID app, when started via the bankid:// URI scheme. For details, see also the BankID Relying Party Guidelines.

The autoStartToken parameter has these purposes:

  • The token ensures that the same/the correct BankID session is bound in the BankID app. That is – the same session that initiated the BankID process somewhere else.
  • If the BankID session was setup with the personal number (an optional parameter), then the only user possible to respond in the app is that particular person. If no personal number was given upon session initiation, any person configured on the local BankID app are legitimate responders to the authentication request.

Here is the PHP code for the demo:

ini_set('display_errors', 1);

if (isset($_GET['pnr'])) {
$request = array( 
	'PersonalNumber' => $_GET['pnr']
$request = array( 

// cURL
$ch = curl_init("");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json; charset=UTF-8',
        'Authorization: YourKeyHere...'
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($request, JSON_UNESCAPED_UNICODE));

// Execute
$result = json_decode(curl_exec($ch));

if (isset($_GET['pnr'])) {
	echo "

BankID session created WITH pnr=".$_GET['pnr'].""; } else{ echo "

BankID session created WITHOUT a pnr
"; } echo "
Click the link below within 30 secs to autostart the BankID app."; echo "
autoStartToken."&redirect=null\">bankid:///?autostarttoken=".$result->autoStartToken."&redirect=null"; echo ""; echo "

EXPLANATION: "; echo "
This demo-page can be called with/without url-argument ?pnr=NNNNNNNNNNNN (12 digits)"; echo "
* If you supply a pnr, only that person can login in the app"; echo "
* If you omit the pnr, any person configured on the app can login."; echo "
The app is started via a custom uri scheme called bankid://"; echo "
(Install the BankID app for TEST on a pc, easy to setup several test persons, to see difference!)"; echo "

The orderRef below can be used with the API to fetch the results after the successful BankID login, "; echo "
however fetching and displaying of the id results is not part of this demo."; echo "
orderRef=".$result->orderRef; echo "
"; ?>