Login hints
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. often has a good idea which account a sign-in is for. It can pass that guess to the provider as a login hint, or point at the exact person with an earlier 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.. Either way, the hint shapes what the provider shows, and the 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. still decides who signed in.
Suggesting an account
All domains, identifiers and tokens in these examples are fictional.
The collage app emails Ava: the proof of her poster is ready to review. She opens the link on her phone, where she has never signed in to the collage app, so it needs her to sign in with her photo account before it shows the proof. Unlike a visitor arriving at its home page, this visitor is someone the collage app can make a good guess about. The proof belongs to her collage account, and that account holds her email address, [email protected]. The collage app can pass that guess along, so the photo service doesn't have to start from nothing.
It adds a login hint to the authorizationDeciding whether a requested action is permitted, such as whether a signed-in account may delete a particular photo. Authentication says which account is asking; authorization decides what it can do. request:
https://auth.photos.example/authorize
?response_type=code
&client_id=photo-collage
&redirect_uri=https%3A%2F%2Fcollage.example%2Fsignin%2Fcallback
&scope=openid%20profile%20email
&state=demo-signin-5
&nonce=demo-nonce-5
&code_challenge=yifcz29Q4ncDY9kb-79GH-Lwj3XpnDAY0NdoxWaKkJI
&code_challenge_method=S256
&login_hint=ava%40mail.examplelogin_hint tells the photo service which login identifier Ava is likely to use. If it has no 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. for her in her phone's browser, its sign-in page can open with [email protected] already filled in, and she goes straight to her password or passkeyA credential that your phone, computer or password manager creates for one website and keeps for you, unlocked with a fingerprint, face or PIN. Nothing you could type is sent, and it works only for the site it was made for, which helps it resist phishing.. If the browser is signed in to more than one photo account, the hint lets the photo service pick hers instead of showing the account chooser from Prompt and account selection, or picking whichever account was used last.
What a hint may contain is up to the provider. An email address is the most common form, and the specification also allows a phone number written the way the phone_number claim writes it. Some providers accept their own usernames, and some accept the subject identifier they issued. The specification leaves the use of the hint entirely to the provider, so the collage app follows the photo service's documentation rather than assuming.
An email address 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. deserves a second thought. The request travels through Ava's browser, so the address is saved in her browser history and can appear in any log that records full URLs. The photo service already knows her address, so the hint tells it nothing new, but the collage app sends one only when it saves her real effort. Where a provider accepts the subject identifier, that value reveals less to anyone else who sees the URL. Pushed authorization requestsAn OAuth extension, RFC 9126, in which the client sends its authorization request straight to the authorization server and gets back a short-lived request_uri. The browser carries only that reference, so the parameters cannot be read or changed on the way., covered in Pushing an authorization request in Advanced 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., keep parameters like this out of the browser altogether: the client sends them to the provider directly, and the browser carries only a reference.
Hinting with an earlier ID token
An email address is a guess about what Ava might type. When the collage app holds an ID token from her current session, it can be exact. The id_token_hint parameter carries an ID token the photo service issued earlier, and tells the photo service that this request concerns the person that token names.
On her phone the collage app had no token to send. On the family laptop it does: it signed Ava in there this morning and keeps the ID token from that sign-in on its server with her session, as Establishing an application session described. Later today it will need to send her back to the photo service while that session is still active, for a reason Session age and reauthentication explains. Whatever the reason, the answer must be about Ava, not about whoever happens to be signed in to the photo service in that browser at the time.
So the request carries one more parameter. The token is shortened here:
&id_token_hint=eyJhbGciOiJSUzI1NiIsImtpZCI6InBob3Rvcy1ycy0yMDI2LTA5IiwidHlwIjoiSldUIn0...The photo service reads the token's subject, user-2048, and compares it with its own session. If Ava is signed in as that account, or signs in as it during the request, the result is an ordinary sign-in. Otherwise the photo service must return an error, such as login_required, rather than a sign-in for someone else.
Suppose Ben, who shares the laptop, signed in to his own photo account in another tab. Without the hint, a silent request from the collage app could come back as a perfectly valid sign-in for Ben. With it, the photo service knows Ben is not the person the collage app is asking about. This matters most with prompt=none, where nobody sees a page that might reveal the mismatch. The specification asks clients to send id_token_hint with prompt=none whenever they have one, and allows a provider to refuse a silent request that arrives without it, although it should answer if it can.
Suggests Ava, Ben signs in
- Request carries
- login_hint for Ava
- Signed in
- Ben, after clearing the form
- Photo service returns
- Ben's sign-in
- Collage app uses
- Ben's validated sub
Ben gets his own account
Ava still signed in
- Request carries
- prompt=none, Ava's ID token
- Signed in
- Ava
- Photo service returns
- A code for user-2048
- Collage app uses
- Ava's validated sub
Silent sign-in for Ava
Ben signed in instead
- Request carries
- prompt=none, Ava's ID token
- Signed in
- Ben
- Photo service returns
- login_required
- Collage app uses
- No sign-in
Nothing about Ben
The same silent request
- Request carries
- prompt=none only
- Signed in
- Ben
- Photo service returns
- A valid sign-in for Ben
- Collage app uses
- Ben's sub, for Ava's session
The wrong person
The validated ID token decides who signed in, never the hint.
A few details make this work. The token's exp passed hours ago, and that is fine: the specification asks only for an ID token the provider issued earlier, because the collage app is not presenting it as proof of a current sign-in, only as a pointer to the person it names. The photo service doesn't need to appear in the token's audience either, which is just as well, because the token was addressed to the collage app. It does need to be a token the photo service itself signed for this client; one from another provider, or for another app, is refused. And the token travels through the browser like the rest of the request. The collage app's ID tokens carry no profile claims, so little beyond Ava's subject identifier is exposed. A token full of profile claims would put all of them in the URL.
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
- Suggest an account with login_hint, pin it with id_token_hintCompare a suggested account with a validated person, use an earlier ID token as a hint, and refuse mismatched or foreign hints.