Get started with Customer Identity
Add a customer, connect your app, and watch the customer allow it on the consent page, find it among their apps, and take it back.
APIRFC 6749, RFC 7636, OpenID Connect Core 1.0
In this page you add a customer, Maya, to your realm, connect your customer-facing app at https://app.example.com,
and follow Maya as she signs in to it. She sees a consent page naming your app and what it asks for, allows it, finds
it on her list of apps, and can take it back whenever she likes.
Before you begin
Section titled “Before you begin”- A realm for your customers. Here it’s
foobar, athttps://foobar.cvyuh.com. Keep customers apart from your staff: see Customer realms. - A realm administrator’s session in
$CVYUH_SESSION, as Call the API describes. - Your app’s return address, here
https://app.example.com/callback, and an OAuth 2.0 or OpenID Connect library in the app. Most read everything else from the realm’s discovery document.
Connect your app and sign a customer in
Section titled “Connect your app and sign a customer in”-
Add Maya. As a realm administrator, create her account:
Terminal window curl "https://foobar.cvyuh.com/api/v0/am/objects/v1/user?id=maya" \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-d '{ "uid": "maya", "displayName": "Maya Chen", "email": "maya@example.com","passwordHash": "<a first password>" }'The realm answers
201. Customers can’t sign themselves up yet; see Registration. -
Register your app. Give it the name customers will see on the consent page in
clientName:Terminal window curl "https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client?id=example-app" \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-d '{"status": "active","clientName": "Example App","tokenEndpointAuthMethod": "client_secret_basic","clientSecret": "<a long random secret>","grantTypes": ["authorization_code", "refresh_token"],"redirectUris": ["https://app.example.com/callback"],"scopes": ["openid", "profile", "email"],"defaultScopes": ["openid"],"allowedResources": ["https://app.example.com/api"],"defaultAudience": "https://app.example.com/api"}'The realm answers
201. The secret is stored hashed and never shown again, so keep a copy for the app. The app’s issuer ishttps://foobar.cvyuh.com/oauth2. -
Send Maya to sign in. When she chooses Sign in in your app, the app sends her browser to the realm, with a PKCE challenge:
https://foobar.cvyuh.com/oauth2/authorize?response_type=code&client_id=example-app&redirect_uri=https://app.example.com/callback&scope=openid%20profile%20email&state=<state>&code_challenge=<S256 challenge>&code_challenge_method=S256Maya signs in on the realm’s pages with her password. A new realm requires a second step, so the first time she also sets up an authenticator app. Once she adds a passkey, she signs in with it alone; see Passkey sign-in for customers.
-
Maya allows your app. The first time, the realm shows her a consent page: Example App, the details it asks for, and the account she’s signed in as. She chooses Allow, and her browser returns to
https://app.example.com/callbackwith a one-timecode. -
Your app gets its tokens. Its server exchanges the code at the token endpoint:
Terminal window curl https://foobar.cvyuh.com/oauth2/token \-u "example-app:<the app's secret>" \-d grant_type=authorization_code \-d code=<code> \-d redirect_uri=https://app.example.com/callback \-d code_verifier=<PKCE verifier>The answer carries an
access_tokenand anid_tokennaming Maya.
Check it worked
Section titled “Check it worked”Maya finds your app on her Authorized Apps page in the dashboard. With her own session, the same list is one call:
curl https://foobar.cvyuh.com/api/v0/am/me/v1/oauth2/apps \ -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"[ { "clientId": "example-app", "clientName": "Example App", "scopes": ["openid", "profile", "email"], "firstGranted": "<RFC 3339 time>", "lastGranted": "<RFC 3339 time>", "offline": false }]The next time she signs in to your app, she isn’t asked again: the realm remembers what she allowed.