Scopes and the claims parameter
The scopes in a sign-in request decide which claims an application can learn about the person. This lesson reads the four scopes that request claims, asks for individual claims with the claims parameter instead, and decides what an application does when a claim never arrives.
Scopes that request claims
When Ava chose to sign in to the collage app with her photo account, the collage app's request carried scope=openid profile email, and the photo service asked whether she was willing to share her profile and email address with the collage app. The words profile and email decided what the collage app could learn about Ava. They also asked for a good deal more than the collage app uses. All domains, identifiers, and values in these examples are fictional.
OpenID ConnectAn identity layer on top of OAuth 2.0 that lets an application sign people in with an account at another service. It adds the ID token, standard claims, and discovery to the OAuth exchange. defines four scope values that request claims. Each one stands for a fixed group:
| Scope | Claims it requests |
|---|---|
profile | name, family_name, given_name, middle_name, nickname, preferred_username, profile, picture, website, gender, birthdate, zoneinfo, locale, and updated_at |
email | email and email_verified |
address | address |
phone | phone_number and phone_number_verified |
The provider treats every claim these scopes request as voluntary: the relying partyAn application that accepts and relies on a sign-in from another service, the name used in OpenID Connect and for passkeys. SAML calls the same role a service provider. would like it, but the sign-in does not depend on it. A person may be able to decline some of them on the consent screen, and the provider may withhold others under its own policy.
These are still OAuthA framework that lets a person give an application limited access to their resources at another service, using tokens instead of sharing their password. OAuth is about access; OpenID Connect adds sign-in. scopes. They describe what the access tokenA token that a client presents to an API to use access it has been granted, usually limited in what it allows and how long it lasts. It authorizes API calls; it does not tell the client who signed in. issued at the end of the exchange may be used for, and here that use is reading claims about Ava. With the authorization code flowThe main OAuth flow: the browser visits the authorization server, where the person signs in and approves access, then carries an authorization code back to the client, which exchanges it for tokens directly. When the client runs on a server, the tokens never pass through the browser., the claims requested by these scopes come back from the UserInfo endpointAn OpenID Provider endpoint that returns claims about the signed-in person to a client presenting an access token. Its sub must match the ID token's before the client uses anything it returns., which the collage app calls with that access tokenA piece of data issued by a trusted service that a client presents as a credential, for example to call an API or to report a sign-in. Some tokens carry readable claims; others are random strings that only the issuer can interpret.. They are placed in the ID tokenIn OpenID Connect, a signed JWT from the provider, addressed to one client, saying which account authenticated, when, and in answer to which request. It reports a sign-in and is not used to call APIs. only when the flow issues no access token at all. That happens only with a response type the collage app does not use, which Response types, response modes, and older flows describes. Many providers also copy a few of them, often a name and an email address, into the ID token. The collage app can read them there when they appear, but its code should not depend on them.
The profile scope is the blunt part of the collage app's request. The collage app uses Ava's given name in greetings and her picture beside her saved collages. Through profile, it also asked for her birth date, gender, website, and time zone. The photo service happens to hold none of those for Ava, but another customer's account might, and a consent screen that mentions a "profile" may not say how much that word covers.
Asking for individual claims
The claims request parameter lets a relying party name the claims it wants one at a time, and say where each one should be returned. Its value is a JSONA text format for structured information, written as named values inside curly braces. APIs, tokens, and discovery documents all use it. object with two defined members. userinfo lists claims to return from the UserInfo endpoint, and id_token lists claims to add to the ID token. A narrower version of the collage app's request could carry this, shown decoded:
{
"userinfo": {
"given_name": null,
"picture": null,
"email": {"essential": true},
"email_verified": {"essential": true}
}
}In the authenticationChecking evidence that someone, or some application, controls an account, such as a password or a passkey. It establishes which account is being used, not what that account may do. request, the JSON is URL-encoded into a single parameter, and the scope shrinks to openid:
scope=openid
&claims=%7B%22userinfo%22%3A%7B%22given_name%22%3Anull%2C...The encoded value is shortened here, and the rest of the request is unchanged. Dropping profile and email from the scope matters. Claims named in the claims parameter are added to whatever the scopes request, so a request that kept profile would still ask for all fourteen of its claims. Because the userinfo member asks for claims from UserInfo, the request must also use a response type that issues an access token, which the authorization codeA short-lived, single-use value that the authorization server sends back to a client through the browser. The client swaps it for tokens in a direct request to the authorization server; APIs never accept it. flow always does.
Each entry says how the claim is wanted. null requests it in the ordinary way, as a voluntary claim. An object can add detail. {"essential": true} marks an essential claim, one the relying party considers important for what the person is trying to do. A provider can use that to explain on the consent screen why the collage app is asking. It is not a guarantee. The provider must not fail the request because a claim could not be returned, essential or not, unless that claim's own definition says otherwise. Authentication context and methods meets the main exception, a requested level of authentication.
An object can also carry value or values, asking for a claim only if it has a particular value or one of a list. A claim that does not match is left out of the response. That is mostly useful for claims about the sign-in rather than about the person. Authentication context and methods uses values to request an authentication context, and a value for sub under id_token tells the provider to fail the sign-in unless that particular account is the one signed in.
Placement is a choice too. Moving email under id_token would put Ava's address inside the signed ID token, so the collage app could read it without calling UserInfo. The cost is that an ID token can travel further than a UserInfo response. A relying party may keep it to send back to the provider later as a hint, in a URLA web address, such as https://photos.example/api/albums/42?limit=10. It names how to connect (https), the domain, the path to a particular page or resource, and any extra parameters after the question mark. that passes through her browser, as RP-initiated logout will show, and any claims inside travel with it. Information the collage app needs only at sign-in is usually better fetched from UserInfo.
Support for the claims parameter is optional. A provider that supports it sets claims_parameter_supported to true in its discovery document, and a missing field means it does not. A provider without support is expected to return whatever set of claims it judges useful, which may be more or less than the collage app asked for. Either way, the collage app works with what actually arrives.
When claims are missing
Suppose Ava clears the box for her email address on the consent screen. The UserInfo response for the narrower request might then be:
{
"sub": "user-2048",
"given_name": "Ava",
"picture": "https://photos.example/avatars/user-2048.jpg"
}The email claims are simply absent. A claim can be missing for several reasons, and the collage app usually cannot tell which. Ava may have declined it. The provider may not hold it, as with a phone number the photo service never had. The provider's policy may withhold it from some relying parties, or it may have ignored a claims parameter it does not support. Some providers also report a narrower scope in the token response, as Exchanging a code for tokens described, but the claims that actually arrive are what count. None of this is an error.
userinfo
- given_name
- null
- picture
- null
- {"essential": true}
- email_verified
- {"essential": true}
sub user-2048
- given_name
- Ava
- picture
- user-2048.jpg
- Simply absent
- email_verified
- Simply absent
It asks Ava for an address and verifies it itself
An essential claim is not a guarantee, and the collage app usually cannot tell why a claim is missing.
The specification asks providers to leave a missing claim out rather than send it as null or an empty string. The collage app treats all three in the same way, and it never reads a missing claim as a default value. A missing email_verified, in particular, is not a quiet way of saying true.
What happens next depends on what the claim was for. Without given_name, the greeting says "Welcome" without a name. Without picture, her collages show her initials. Without an email address on a first sign-in, the collage app still needs somewhere to send receipts, so it asks Ava for an address and verifies it itself, by sending a code, before relying on it.
Two reactions make things worse. Failing the sign-in punishes Ava for a choice the provider offered, even though the ID token has already established who she is. Sending her back to the photo service again and again, hoping for a different answer, ignores an answer she or the provider have already given.
The opposite happens too. A provider can return claims the collage app did not ask for, or more than it needs. The collage app reads what each feature uses and leaves the rest behind rather than storing everything that arrived. Claim stability and privacy explains why that restraint matters.
Check your understanding
Try these questions before moving on. If an answer isn't right, use the feedback and try again.
Try it in the Lab
- Map scopes to the claims they release, and handle claims that never arriveBuild your tenant's scope-to-claim table, move profile claims into UserInfo, ask for single claims with the claims parameter, let Ava leave out a scope at consent, and keep signing people in when claims are missing.