Skip to content
Workforce IdentityMarkdown

Sign users in to your own native app

Let your own mobile or desktop app sign users in with its own screens, without opening a browser.

APIOAuth 2.0 for First-Party Applications (draft)

Your organization’s own mobile or desktop app can show its own sign-in screens and walk users through the realm’s sign-in steps: username and password, then a one-time code if the realm asks for one. At the end it gets a code and exchanges it for tokens, as any app does. No browser opens.

Before you start:

  • Who can do it: a realm administrator, in a group that holds RealmOwner (Delegated administration). RealmViewer can read the settings but not change them.
  • Where: today this is done through the API; Call the API shows how to get $CVYUH_SESSION.
  • First: be sure the app is truly your organization’s own.
  1. Allow first-party sign-in in the realm:

    Terminal window
    curl -X PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Settings/oauth2Settings \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "firstPartyAppsAllowed": true }'
  2. Register the app and mark it as yours with firstParty:

    Terminal window
    curl 'https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client?id=field-app' \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{
    "status": "active",
    "clientName": "Field App",
    "tokenEndpointAuthMethod": "none",
    "firstParty": true,
    "grantTypes": ["authorization_code", "refresh_token"],
    "scopes": ["openid", "profile", "offline_access", "field:read"],
    "defaultScopes": ["openid", "field:read"],
    "allowedResources": ["https://field.example.com/api"],
    "defaultAudience": "https://field.example.com/api"
    }'
  3. Optionally, offer a stronger sign-in by name: map an acr value to a sign-in chain, as in Step up for sensitive actions.

  1. The app starts at POST https://foobar.cvyuh.com/oauth2/authorize-challenge with what a browser sign-in carries: scopes, the API it wants, and its PKCE challenge.
  2. The realm answers insufficient_authorization with the next step to show, and an auth_session to send back with the answers.
  3. The app repeats until the realm answers with a code. A failed sign-in is access_denied.
  4. The app redeems the code at the token endpoint.

The user sees the app’s own screens, one for each step the realm asks for: a two-step sign-in takes two screens. There’s no consent page, because the app and the realm are one party. The exception is offline access, which the user must have allowed earlier through the browser sign-in.

  • Each auth_session is answered once, by this app only, within ten minutes.
  • A sign-in begun with a DPoP proof must use the same key throughout.
  • The session is real: signing out ends it.
  • An agent’s client is always refused, whatever it is marked.

Sign in through the app as a test user. A wrong password should be refused, and a right one should end in a code. Each step is on the user’s trail as with a browser sign-in (LOGIN_STARTED, MODULE_COMPLETED, then LOGIN or LOGIN_FAILED), and a wrong password counts toward Lockout. Find them in Audit → Authentication in the dashboard.

SymptomCauseFix
unauthorized_client, “may not sign a person in without a browser”firstPartyAppsAllowed is off, or the client isn’t firstPartyDo steps 1 and 2
unauthorized_client for an agent’s clientAn agent never signs a person in this wayUse Let an agent act for a user
unauthorized_client, “may not use the authorization code grant”The realm or the client lacks authorization_codeAdd it to the client’s grantTypes
An old auth_session is refusedIt was answered already, or ten minutes passedStart the sign-in again
No refresh tokenOffline access must first be allowed through the browser sign-inHave the user allow it once in the browser

Set the client’s firstParty to false, or the realm’s firstPartyAppsAllowed to false to stop it for every app.