Connecting a sign-in to an account
A validated 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. says who the provider authenticated, but 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. still has to decide which of its own accounts that sign-in opens. It builds that connection on 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 subject pair, keeps everything else as labeled copies, and gives each account an identifier of its own.
The first sign-in
All domains, identifiers and tokens in these examples are fictional.
Ava chooses Continue with your photo account on the collage app's sign-in page for the first time. A moment later the collage app has done everything described from Following a complete sign-in to The UserInfo endpoint. It has exchanged the code, validated the 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. and its nonceA random value used for one attempt only. In OpenID Connect, the client sends one in its sign-in request and checks that the same value comes back inside the ID token, showing the token answers this attempt., and fetched her profile 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.. It knows that the photo service has just authenticated user-2048, and that the account's name is Ava Archer and its email address is [email protected].
What it doesn't know yet is which collage app account she means. Saved collages, print orders and delivery addresses all belong to collage app accounts, and the sign-in has to lead to one of them. Claim stability and privacy ended with the rule that decides how: of everything the photo service sends, only the issuer and the subject together identify her. The collage app builds its accounts on that pair.
The collage app keeps a table of sign-in identities, with one row for each provider account that may open a collage app account. It looks there for the pair from the validated ID token:
Issuer: https://auth.photos.example
Subject: user-2048There is no row. That tells the collage app only that this photo account has never been used to sign in here. It doesn't tell it that Ava is a new customer. She might have opened a collage app account with a password long before the photo button existed, and nothing in the ID token can distinguish those two situations.
A relying party can handle the missing row in two ways. It can create an account at once, using the claims as starting values, so the first sign-in feels like every later one. That is quick, but it creates accounts for people who were only looking around, and it adopts a name and address the person never reviewed. Or it can ask for registration details first: show a short form filled in from the claims, ask for anything the provider doesn't supply, such as agreement to the app's terms, and create the account only when the person confirms.
The collage app asks. Its registration page greets Ava Archer and offers two choices: create a new collage app account with the details shown, or sign in to an existing collage app account and connect this photo account to it.
While that page is open, the collage app has to remember who signed in. The validated issuer and subject stay on its server, in a pending registration attached to Ava's 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.:
Pending registration (expires 15 minutes after the sign-in)
Issuer: https://auth.photos.example
Subject: user-2048
Claims: name Ava Archer, email [email protected], email_verified trueThe form carries only what Ava is allowed to choose. If the issuer and subject traveled in hidden form fields, the browser would send them back, and whoever submitted the form could put a different subject there and create an account tied to someone else's photo account. The identity has to come from the validated ID token, by a route the browser can't touch. If Ava abandons the page, the pending registration expires and nothing is created.
A new customer who chooses to create an account gets a new collage app account and a row linking it to their pair, written in one transaction so neither can exist without the other. Ava has had a collage app account since her first collage, so she chooses the second option instead. Linking accounts follows that path. Either way, the result is the same kind of row.
Returning customers
Once a row connects the pair to an account, every later sign-in is a lookup. The next time Ava signs in, the collage app reaches this point and runs:
SELECT account_id
FROM sign_in_identities
WHERE issuer = 'https://auth.photos.example'
AND subject = 'user-2048';The row points to collage app account 8812, which is Ava's. No other claim takes part in finding it.
The comparison is exact. Both values are case-sensitive strings, so the collage app doesn't lowercase them, trim them, or treat User-2048 as the same subject. The issuer is the one the collage app configured for the photo service and validated the token against, compared character for character.
The table itself enforces the important rule:
CREATE TABLE sign_in_identities (
account_id TEXT NOT NULL REFERENCES accounts(id),
issuer TEXT NOT NULL,
subject TEXT NOT NULL,
linked_at TEXT NOT NULL,
UNIQUE (issuer, subject)
);UNIQUE (issuer, subject) means a pair can appear only once, so one photo account can never open two collage app accounts. The rule covers the pair, not the subject alone. When the collage app adds the mail service as a second provider, Ava's account there arrives with the subject a94f1c07e2, and as Supporting several providers pointed out, another provider is free to issue user-2048 to someone else entirely. A lookup by subject alone could hand that stranger Ava's account. Account 8812 can have several rows, one for each provider she links, and each row is checked on its own.
A lookup by email address would fail in the ways Claim stability and privacy described. If Ava changes her address at the photo service to [email protected], the pair still finds account 8812, and the collage app updates its copy of the address. A lookup by email would find nothing and offer her a second account, or find an account that now belongs to whoever has been given her old address.
Ava returns
- Issuer
- auth.photos.example
- Subject
- user-2048
- [email protected]
- Pair lookup
- Account 8812
- Email lookup
- Account 8812
Both find her account
Ava changed her address
- Issuer
- auth.photos.example
- Subject
- user-2048
- [email protected]
- Pair lookup
- Account 8812
- Email lookup
- Nothing found
The pair still finds her
New owner of her old address
- Issuer
- accounts.mail.example
- Subject
- A different subject
- [email protected]
- Pair lookup
- No account: a new customer
- Email lookup
- Account 8812
Email would open her account
Only the issuer and the subject together identify her.
Two outcomes need more than a plain match. If the row points to an account the collage app has suspended or closed, a valid ID token doesn't reopen it: the provider vouches for who signed in, and the collage app still decides what that person may do. And if the lookup fails for people the collage app expects to recognize, for example after a provider moves to a new issuer identifier, or after a change of host alters pairwise subjects as Public and pairwise subject identifiers described, the collage app has a migration to plan. Falling back to matching email addresses is not a way to cover the gap.
What the account stores
After Ava's photo account is linked, a simplified view of the collage app's records for her looks like this:
Account 8812
Display name: Ava Archer
Contact email: [email protected] (confirmed by the collage app, 2025-11-14)
Password: set
Collages, print orders and delivery addresses refer to 8812
Sign-in identities for account 8812
https://auth.photos.example user-2048 linked 2026-09-28 18:12 UTC
Profile copied from https://auth.photos.example
name Ava Archer
email [email protected] (email_verified true)
updated_at 1788220800 (2026-09-01 00:00 UTC)
copied 2026-10-01 09:00 UTCThree choices in that record matter.
The account has its own identifier. Collages, print orders and addresses all refer to account 8812, never to user-2048. If the collage app had used the subject as its account ID, Ava's account would effectively belong to the photo service: a second provider would need a second account, and removing the photo sign-in would strand her collages. Identity rows are ways into an account, and the account outlives any one of them.
The profile is a copy, labeled with where it came from. Ava entered her display name and contact email when she registered. The photo service's name and email sit beside them as statements it made at one moment; for a customer who signed up through the photo service, they would have supplied the starting values. Recording the source and the provider's updated_at claim, the time the provider last changed the profile, lets the collage app replace the copy when newer values arrive at a later sign-in, and keep apart what Ava typed, what the app confirmed itself and what it only received.
The contact email shows why that matters. The collage app sent its own confirmation link to [email protected] when Ava registered, and that confirmation, not the photo service's email_verified, is why it trusts the address for password resets. If the photo service later reports a different address, the collage app can offer to use it, and confirm it before relying on it for anything that could hand over the account.
And the record leaves things out. It holds no ID token, no UserInfo response and no 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.. Those were evidence for one sign-in, and keeping them would only create something else to protect. The copied profile holds the claims the collage app actually uses and nothing more.
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
- Key accounts on issuer and subject across two providersSign in as two different people who share one email address at two providers, store each as an issuer and subject pair, and see a pair lookup and an email lookup disagree.