Theme
Open the portal

Kiosks and counters

A customer signs up at your kiosk or counter by scanning a QR code or holding their phone against the screen, instead of typing. Your kiosk shows a detached Sign in with allme link; the customer approves it in the allme app on their own phone; your backend collects the result.

Nothing here is kiosk-specific on the allme side: it is the detached response mode of Sign in with allme. What this page adds is how to show the link at a kiosk, and the Android kiosk library that shows it as a QR code and presents it over NFC.

1. Register an identity app

In the allus portal → Configuration → OAuth apps, create an app as Sign in with allme describes. Keep its credentials on your kiosk’s backend, never on the kiosk device: the backend builds every link and collects every result. For connect mode, reference the service the customer connects to.

2. Build the link on your backend

For each customer, the backend builds an authorize link with:

A public app adds its PKCE challenge, as for any sign-in.

3. Show it at the kiosk

Install the library from JitPack:

// settings.gradle.kts
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven("https://jitpack.io")
    }
}

// build.gradle.kts of the kiosk app
dependencies {
    implementation("com.github.allus-fyi:allme-kiosk-android:v0.1.0")
}

Then, in the kiosk’s activity:

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    KioskLink.attach(this)          // win any NFC conflict while this screen is in front
    setContent {
        val link = kioskLink        // the link your backend built for the next customer
        KioskQr(url = link, modifier = Modifier.fillMaxWidth())
        LaunchedEffect(link) {
            // false on a device without NFC card emulation: the QR code still works
            KioskLink.present(this@KioskActivity, link, System.currentTimeMillis() + 10 * 60 * 1000L)
        }
    }
}

Call KioskLink.stop(context) when the kiosk stops offering the link. A presented link also stops on its own at the moment you gave present.

4. The customer approves on their phone

Scanning the QR code or holding the phone against the kiosk opens the link. With the allme app installed, the link opens in the app (Open the allme app from your button), which shows its own approve screen; without the app, the allme web page opens instead. In connect mode the customer answers your service’s request fields on that screen.

5. Collect the result on your backend

While the link is shown, your backend polls /oauth2/result with the link’s state until the customer has approved. Each SDK’s poll_result does the polling and returns the authorization code, which you exchange as for any sign-in:

import secrets
from allus_company_data import OAuthClient

oauth = OAuthClient.from_config("idw.json")
state = secrets.token_urlsafe(24)                    # fresh for every customer
url = oauth.authorize_url("signin", response_mode="detached", state=state)
# hand url to the kiosk to show as a QR code and present over NFC

result = oauth.poll_result(state)                    # waits until the customer approves
sign_in = oauth.complete_sign_in(result["code"])
print(sign_in["user"]["sub"])
import { randomBytes } from "node:crypto";
import { OAuthClient } from "@allus-fyi/company-data";

const oauth = OAuthClient.fromConfig("idw.json");
const state = randomBytes(24).toString("base64url");  // fresh for every customer
const url = oauth.authorizeUrl("signin", { responseMode: "detached", state });
// hand url to the kiosk to show as a QR code and present over NFC

const result = await oauth.pollResult(state);         // waits until the customer approves
const signIn = await oauth.completeSignIn(String(result.code));
console.log(signIn.user.sub);
use Allus\CompanyData\OAuthClient;

$oauth = OAuthClient::fromConfig('idw.json');
$state = rtrim(strtr(base64_encode(random_bytes(24)), '+/', '-_'), '=');   // fresh for every customer
$url = $oauth->authorizeUrl('signin', state: $state, responseMode: 'detached');
// hand $url to the kiosk to show as a QR code and present over NFC

$result = $oauth->pollResult($state);                // waits until the customer approves
$signIn = $oauth->completeSignIn($result['code']);
echo $signIn['user']['sub'];
import (
    "crypto/rand"
    "encoding/base64"
    "fmt"
    "log"
    "time"

    "github.com/allus-fyi/company-data-go/companydata"
)

oauth, err := companydata.OAuthClientFromConfig("idw.json")
if err != nil {
    log.Fatal(err)
}
nonce := make([]byte, 24)
rand.Read(nonce)
state := base64.RawURLEncoding.EncodeToString(nonce)   // fresh for every customer
authURL, err := oauth.AuthorizeURL("signin", &companydata.AuthorizeURLOptions{ResponseMode: "detached", State: state})
if err != nil {
    log.Fatal(err)
}
// hand authURL to the kiosk to show as a QR code and present over NFC

result, err := oauth.PollResult(state, 10*time.Minute, 2*time.Second)   // waits until the customer approves
if err != nil {
    log.Fatal(err)
}
signIn, err := oauth.CompleteSignIn(result["code"].(string), "")
if err != nil {
    log.Fatal(err)
}
fmt.Println(signIn.User["sub"])
using System.Security.Cryptography;
using Allus.CompanyData;

var oauth = OAuthClient.FromConfig("idw.json");
var state = Convert.ToBase64String(RandomNumberGenerator.GetBytes(24))
    .TrimEnd('=').Replace('+', '-').Replace('/', '_');           // fresh for every customer
var url = oauth.AuthorizeUrl("signin", state: state, responseMode: "detached");
// hand url to the kiosk to show as a QR code and present over NFC

var result = await oauth.PollResultAsync(state);                 // waits until the customer approves
var signIn = await oauth.CompleteSignInAsync(result.GetProperty("code").GetString()!);
Console.WriteLine(signIn.Sub);
import fyi.allme.allus.companydata.OAuthClient;
import java.security.SecureRandom;
import java.util.Base64;
import java.util.Map;

OAuthClient oauth = OAuthClient.fromConfig("idw.json");
byte[] nonce = new byte[24];
new SecureRandom().nextBytes(nonce);
String state = Base64.getUrlEncoder().withoutPadding().encodeToString(nonce);   // fresh for every customer
String url = oauth.authorizeUrl("signin", new OAuthClient.AuthorizeOptions()
    .responseMode("detached")
    .state(state));
// hand url to the kiosk to show as a QR code and present over NFC

Map<String, Object> result = oauth.pollResult(state, 600, 2);   // waits until the customer approves
OAuthClient.SignInResult signIn = oauth.completeSignIn((String) result.get("code"), null);
System.out.println(signIn.user().get("sub"));

The result is delivered once. The poll’s answers and errors are those of Sign in with allme, step 3.

6. One link for at most 10 minutes

An approved detached sign-in waits 10 minutes for your backend to collect it. So a kiosk shows one link for at most 10 minutes; then it shows a new link, built with a new state. Pass the same moment to KioskLink.present as its end, so the NFC tag stops with the QR code. After each customer, show a new link the same way.

iPhone, iPad and web kiosks

An iPhone or iPad app cannot present an NFC tag, and a web page cannot either. A kiosk on those shows the QR code only; everything else on this page is the same.