Skip to content
Workforce IdentityMarkdown

First-party app sign-in

Your own native app signs users in with its own screens, running the realm's sign-in steps directly, without a browser.

AvailableAPIOAuth 2.0 for First-Party Applications (draft)

Your own mobile or desktop app shows its own sign-in screens and sends the user’s answers to the realm, step by step. The realm runs the same sign-in steps as its web pages, and at the end returns a code that the app trades for tokens, as in a browser sign-in. The sign-in is a real session: signing out, back-channel logout and step-up all apply to it.

Use it only for apps that are truly yours, where the realm and the app are the same organization. The app sees the user’s password, which is why it is off by default and you must mark both the realm and the client. For any other app, use the browser sign-in.

  • Who can do it: a realm administrator (a group holding RealmOwner) turns it on and marks the client; RealmViewer can read both but not change them.
  • Where: today this is done through the API (Call the API shows how to get $CVYUH_SESSION).
  • First: the app is registered, with authorization_code among its grants.

1. The app starts the sign-in at the authorization challenge endpoint, with what a browser sign-in carries: scopes, the API it wants and its PKCE challenge. It proves who it is as at the token endpoint (a public app sends only its client_id):

Terminal window
curl https://foobar.cvyuh.com/oauth2/authorize-challenge \
-d client_id=field-app \
--data-urlencode 'scope=openid field:read' \
--data-urlencode resource=https://field.example.com/api \
-d code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM \
-d code_challenge_method=S256

2. The realm answers with the first step to show. It’s a 400 with the error insufficient_authorization, the step’s prompts in callbacks, and an auth_session to send back:

{
"error": "insufficient_authorization",
"header": "Sign in",
"callbacks": [
{ "type": "NameCallback", "output": [{ "name": "prompt", "value": "User Name:" }],
"input": [{ "value": "" }] },
{ "type": "PasswordCallback", "output": [{ "name": "prompt", "value": "Password:" }],
"input": [{ "value": "" }] }
],
"auth_session": "eyJhbGciOi…"
}

The prompts are in the language the app asks for with Accept-Language.

3. The app sends the user’s answers as callbacks, a JSON array in a form field, with the auth_session:

Terminal window
curl https://foobar.cvyuh.com/oauth2/authorize-challenge \
-d client_id=field-app \
-d auth_session=eyJhbGciOi… \
-d 'callbacks=<the callbacks below, URL-encoded>'

Decoded, callbacks is:

[
{ "type": "NameCallback", "input": [{ "value": "maya" }] },
{ "type": "PasswordCallback", "input": [{ "value": "…" }] }
]

If the realm asks for more, such as a one-time code, it answers with the next step and a new auth_session, and the app repeats. Once the sign-in is done, it answers 200:

{ "authorization_code": "eyJhbGciOi…" }

4. The app redeems the code at the token endpoint as any code, with its code_verifier. It sends no redirect_uri, since the code was sent to none.

These steps use the admin API; Call the API shows how to get a session.

  1. Turn it on for the realm: set firstPartyAppsAllowed to true with PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Settings/oauth2Settings.
  2. Mark the app’s client: set firstParty to true in https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client, with authorization_code among its grantTypes.
  3. Point the app at https://foobar.cvyuh.com/oauth2/authorize-challenge.
WhereSettingWhat it does
RealmfirstPartyAppsAllowedOffers first-party sign-in at all (default off). While it’s on, discovery publishes authorization_challenge_endpoint
ClientfirstPartyMarks this client as yours
Realm and clientgrantTypes includes authorization_codeNeeded on both
RealmacrValuesLets the app ask for a stronger sign-in by name (step-up)

Only the app’s own screens. The realm sends each step’s prompts (username, password, a code from an authenticator app) and the app draws them. A wrong answer counts toward the realm’s lockout as on the realm’s own pages, and the warning before a lock comes back with the step for the app to show.

Setting or limitDefaultRange
firstPartyAppsAllowedoffon or off
firstParty on a clientoffnever on for an agent’s client
Time to answer each stepten minutesfixed
A first-party code under FAPI 2.0at most a minutefixed
SymptomCauseFix
unauthorized_client on the first callThe realm or the client isn’t marked first-party, or a grant is missingTurn on firstPartyAppsAllowed, set firstParty, add authorization_code to both grantTypes
invalid_session halfway throughThe user took more than ten minutes on a step, or the app resent an answered auth_sessionStart again; always send the newest auth_session
consent_requiredThe app asked for offline_access the user never allowedHave the user allow it once through the browser sign-in

The sign-in writes LOGIN and its steps (or LOGIN_FAILED) as a browser sign-in does, and the code’s redemption a TOKEN_ISSUED record with grantType authorization_code. See them in Audit → Authentication.

  • An agent’s client is never first-party. An agent that held a user’s password could act as them without anyone seeing it was an agent. Agents reach a user’s access through token exchange instead.
  • Consent is not asked, since the app and the realm are one party. The exception is offline access: the user must have allowed it earlier, through the browser sign-in.
  • Each auth_session is answered once, only by the client that started it, and within ten minutes of the step before.
  • A sign-in begun with a DPoP key must use the same key throughout.
  • acr_values picks the sign-in chain by name (step-up). prompt, max_age and login_hint are ignored.
  • Under the FAPI 2.0 profile, a first-party code lives at most a minute.
ErrorWhen
insufficient_authorizationNot a failure: the next step to show, with a new auth_session
invalid_sessionThe auth_session is expired, another client’s, already answered, or not the realm’s own; or the sign-in timed out. Start again
access_deniedThe sign-in failed, such as a wrong password, or the user can’t be issued tokens
consent_requiredThe app asked for offline_access, and the user hasn’t allowed it through the browser sign-in
unauthorized_clientThe realm or the client isn’t marked first-party, the client is an agent’s, or either doesn’t take the authorization code grant
invalid_dpop_proofThe proof isn’t by the key the sign-in began with
invalid_requestcallbacks isn’t a JSON array, or the PKCE challenge is missing or not S256
invalid_client (401)The client didn’t prove who it is