Authentication errors
Not every sign-in ends with an 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.. 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. errors work as they did in Errors and denied access. 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. adds a few error codes of its own, and one rule that matters more than any of them: the collage app signs no one in unless a validated ID 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. says who they are.
Errors from the provider
Ava might decide at the photo service that she would rather not share her email address with the collage app. The photo service might be unable to sign her in without showing a page, after the collage app asked it not to show one. Or the exchange might fail partway, leaving the collage app with an 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. and nothing else.
When the request reaches the photo service but cannot succeed, and the return address is valid, the photo service sends Ava's browser back with an error instead of a code. All domains and values in these examples are fictional:
https://collage.example/signin/callback
?error=access_denied
&state=demo-signin-3
&iss=https%3A%2F%2Fauth.photos.exampleThe collage app handles this like a successful response up to the point where a code would be used. It finds the pending attempt by state, checks the browser sessionThe ongoing connection between later requests and an earlier sign-in, so you are not asked for your password on every click. It is often tracked with a cookie holding an unpredictable session identifier. and the issuerThe party that creates and signs a token, assertion, or certificate, named in a token's iss claim. A recipient must check that the issuer is exactly the one it expected and trusts., and marks the attempt finished so it cannot be resumed. An error that matches no pending attempt in this session is treated like any other unexpected request to the callback.
Alongside OAuth error codes such as access_denied, invalid_request, invalid_scope, server_error, and temporarily_unavailable, OpenID Connect defines codes that explain why the provider could not finish a sign-in:
| Error | What it means |
|---|---|
login_required | The provider needs the person to authenticate, but the request asked it not to show any pages. |
consent_required | The person has not agreed to share what was requested, and the provider was asked not to show a consent page. |
account_selection_required | The person is signed in to more than one account at the provider and needs to choose one, but the provider was asked not to show the choice. |
interaction_required | Some other interaction is needed, and the provider was asked not to show it. |
OpenID Connect also defines errors for advanced request formats, such as request_not_supported from a provider that does not accept a request packaged as a signed object. The collage app's simple request won't meet those.
Any error may arrive with an error_description. That text is written by the provider for developers, so the collage app does not show it to Ava as if it were its own message, and never inserts it into a page as markup.
When no one can be asked
Most of the OpenID Connect error codes share a condition: the provider was asked not to show a page. That request is prompt=none, which asks the provider to complete the sign-in silently or not at all. A 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. might use it to find out whether Ava is still signed in at the provider without interrupting what she is doing.
In that situation, login_required is not a failure. It answers the question the collage app asked: no, the photo service cannot sign this person in without their involvement. The collage app then decides whether to show its sign-in page, start an interactive request, or carry on without a signed-in customer. Prompt and account selection, in Controlling 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., covers silent requests and their limits in today's browsers.
The same error in answer to an ordinary interactive request would be surprising, because the provider should have shown its sign-in page instead. That is worth recording and investigating.
Failing closed
Errors are not limited to the redirect. The token request can be rejected with invalid_grant, invalid_client, or another OAuth error, or it can time out with no confirmed result. The collage app handles those as Errors and denied access described, and offers a fresh attempt rather than replaying the code.
One outcome is new. Suppose the token response succeeds but contains no id_token, or one that fails validation. The collage app has an access token in hand. It could call 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. and find out whose account the token belongs to.
It must not. UserInfo answers questions about an account for whoever holds a suitable access token. It does not say that this sign-in was the one the collage app started, when Ava authenticated, or that the provider meant its answer for the collage app. Those are the things the ID token establishes, and a response without a valid one has not established them. A fallback like this would also turn every broken response into a successful sign-in, which is the opposite of what a failure should do. The same holds for every check in Validating an ID token: none of them has a fallback that signs the person in anyway.
For Ava, the result should be a clear message and a way forward, such as: "We couldn't sign you in with your photo account. Try again, or sign in another way." A denial she chose deserves a calmer message than an unexpected failure, but neither should leave her looking signed in when she is not.
For the developers, the collage app records the stage that failed, the error code or failed check, the expected issuer, and a correlation ID. It never records the code, the tokens, or the full callback 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..
An ID token that does arrive is still only a claim until it has been checked.
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
- Receive every sign-in error your tenant can return, and handle each safelyProduce access_denied, consent_required and login_required, with no session and with a hint for another account, at your callback, handle each one, and log the failures without codes or tokens.