Identity & access
Sign in from a mobile app
Public client PKCE for iOS and Android: custom schemes, deep-link callbacks and secure storage without a secret.
A mobile application is a public client. It cannot keep a secret, so it uses public_pkce — the same authorization code flow, with no client secret and PKCE doing the work of binding the code to the device that started it.
Register the client
- Profile
public_pkce. The response answershasSecret: false; there is nothing to store. - Register a custom scheme redirect such as
com.acme.app://auth/callback. A native client may not claim HTTPS on a loopback host. - Up to 10 redirect URIs per client, no wildcards fragments or whitespace, exact match only.
The flow
import * as AuthSession from "expo-auth-session";
import * as Crypto from "expo-crypto";
const discovery = await AuthSession.fetchDiscoveryAsync(ISSUER);
const request = new AuthSession.AuthRequest({
clientId: CLIENT_ID,
redirectUri: AuthSession.makeRedirectUri({ scheme: "com.acme.app", path: "auth/callback" }),
responseType: AuthSession.ResponseType.Code,
scopes: ["openid", "profile", "email", "offline_access"],
usePKCE: true,
extraParams: { nonce },
});
const result = await request.promptAsync(discovery);
if (result.type === "success") {
const tokens = await AuthSession.exchangeCodeAsync(
{
...request,
code: result.params.code,
extraParams: { code_verifier: request.codeVerifier! },
},
discovery,
);
}Storage
- Keep the refresh token in the platform keystore (
expo-secure-store, iOS Keychain, Android EncryptedSharedPreferences). - Keep the access token in memory and re-mint it from the refresh token on cold start.
- Sign out means revoke, then clear:
POST /token/revocationwith the refresh token, then delete it locally.
Two identity providers are not needed
Do not bolt on a separate mobile identity. The sub returned here is the same sub the web app sees, which is what lets a person's work follow them between the counter and the back office.
Something here out of date or unclear?
The platform team answers integration questions directly.
