# AADSTS50020: Account from identity provider not in tenant

Canonical: https://brambrinkmeier.com/entra/aadsts/50020/
By Bram Brinkmeier. JSON: https://brambrinkmeier.com/api/aadsts/50020.json

**Short answer:** AADSTS50020 means an account from another identity provider or tenant tried to sign in to an app in your tenant, and that account isn't a user or guest there. It is usually a B2B or app misconfiguration: wrong tenant, uninvited guest, single-tenant app. Repeated hits can also reveal orphaned guest accounts that need cleanup.

**Fix:** User: sign out, then sign in with the account your organisation gave you. Partner? Ask your contact to invite you as a guest. Admin: invite the user via B2B if they need access. For a guest that used to work, reset the guest's redemption status instead of deleting and re-inviting.

| Field | Value |
|---|---|
| Code | AADSTS50020 |
| Microsoft name | UserUnauthorized |
| Category | Guests and tenants |
| Type | Failure |
| Attack signal | Low: usually configuration or user error |
| Where to look | `SigninLogs` |
| In Microsoft's error reference | Yes |
| Verification | documentation |
| Last updated | 2026-10-25 |

## What does AADSTS50020 mean?

Microsoft's description:

> **UserUnauthorized**: Users are unauthorized to call this endpoint. User account '{email}' from identity provider '{idp}' does not exist in tenant '{tenant}' and cannot access the application '{appid}'({appName}) in that tenant. This account needs to be added as an external user in the tenant first. Sign out and sign in again with a different Microsoft Entra user account. If this user should be a member of the tenant, they should be invited via the B2B system.

## Is it an attack?

Usually not. Microsoft's troubleshooting article lists these causes:

- A personal Microsoft account used to sign in to an admin portal.
- A single-tenant app (`signInAudience`) being used by accounts from another tenant.
- The app sends users to the wrong authority endpoint (`/common` versus a specific tenant).
- The user is signed in to the wrong tenant in the browser.
- The external user was never invited as a guest.
- The app requires assignment.
- ROPC (username/password flow) used with personal accounts.
- The user was deleted and re-created in their home tenant, which leaves the old guest object in your tenant **orphaned**.

| Pattern | Likely meaning |
|---|---|
| A partner user, first time on an app | Not invited yet, or wrong tenant in the link. Benign. |
| A known guest who used to work, now fails | **Orphaned guest.** Their home account was re-created. Lifecycle cleanup, not an attack. |
| Your own staff on a partner's app | Wrong authority or single-tenant app on the partner side. Benign. |
| Many different external identities you never invited, against one or several of your apps | Someone checking which of your apps accept outside accounts. Investigate. |

The last row is **our reasoning**, not a Microsoft statement. Microsoft documents 50020 as a configuration error. The orphaned-guest case is the more useful finding for most tenants: it shows guest objects whose real-world identity no longer matches.

## How do I find it in my logs (KQL)?

Which external identities hit 50020, against which apps:

```kusto
SigninLogs
| where TimeGenerated > ago(14d)
| where ResultType == "50020"
| summarize Attempts = count(),
            Apps = make_set(AppDisplayName, 10),
            IPs = make_set(IPAddress, 10),
            HomeTenants = make_set(HomeTenantId, 5),
            FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated)
          by UserPrincipalName
| sort by Attempts desc
```

Possible probing: one IP, many distinct external identities:

```kusto
SigninLogs
| where TimeGenerated > ago(7d)
| where ResultType == "50020"
| summarize Identities = dcount(UserPrincipalName),
            Apps = make_set(AppDisplayName, 10),
            Attempts = count()
          by IPAddress
| where Identities >= 5
| sort by Identities desc
```

The `UserPrincipalName` on a 50020 row is the identity that tried to sign in, which by definition isn't a user in your tenant. Check one row in your workspace to see how it is filled before you rely on it; the email in the error message may be hidden or differ. The threshold of 5 is a starting point, not a tested value.

To find orphaned guests, compare the identities above with your guest list. A guest whose email matches a 50020 identity existed in your tenant but no longer matches its home account.

## How does Conditional Access affect it?

- 50020 is not a Conditional Access result. The account isn't in your tenant, so there is no user for your policies to evaluate.
- Once the external user is invited and redeems the invitation, your policies for guests and external users apply to them like any other sign-in. Have those guest policies in place before you invite.
- Cross-tenant access settings decide which outside organisations can collaborate at all. They are the place to limit B2B access, not exclusions in individual apps.

## How do I fix AADSTS50020?

**For the user:** sign out, then sign in again with the account your organisation gave you. If you are a partner, ask your contact to invite you as a guest.

**For admins and developers:**
1. Check the tenant and app in the error. If the user should have access, invite them via B2B.
2. For an orphaned guest (home account re-created), reset the guest's redemption status. Microsoft's article: *"Reset the redemption status of the guest user account in the resource tenant. Then, you can keep the guest user object without having to delete and then re-create the guest account."*
3. For your own app: check `signInAudience` and the authority URL. A multi-tenant app shouldn't send users to a single tenant's endpoint, and a single-tenant app shouldn't be offered to outside users.
4. Review guest accounts on a schedule. Orphaned guests are inactive objects with access rights that nobody uses.

## Practice the attack side

The [Whose email is it? lab](https://brambrinkmeier.com/labs/tenant-trust/) is a local exercise where a multi-tenant app trusts a token from any tenant and looks users up by email.

## Evidence

Not reproduced in the lab yet; the page is based on Microsoft's documentation.

## Sources

1. [Microsoft Entra authentication and authorization error codes](https://learn.microsoft.com/en-us/entra/identity-platform/reference-error-codes)
2. [Troubleshoot error AADSTS50020 (user account from identity provider does not exist in tenant)](https://learn.microsoft.com/en-us/troubleshoot/entra/entra-id/app-integration/error-code-aadsts50020-user-account-identity-provider-does-not-exist)
3. [SigninLogs table reference (Azure Monitor)](https://learn.microsoft.com/en-us/azure/azure-monitor/reference/tables/signinlogs)

## Related codes

[AADSTS90072](https://brambrinkmeier.com/entra/aadsts/90072/), [AADSTS50034](https://brambrinkmeier.com/entra/aadsts/50034/), [AADSTS700016](https://brambrinkmeier.com/entra/aadsts/700016/), [AADSTS50105](https://brambrinkmeier.com/entra/aadsts/50105/), [AADSTS50011](https://brambrinkmeier.com/entra/aadsts/50011/), [AADSTS16000](https://brambrinkmeier.com/entra/aadsts/16000/), [AADSTS50059](https://brambrinkmeier.com/entra/aadsts/50059/), [AADSTS50194](https://brambrinkmeier.com/entra/aadsts/50194/), [AADSTS51004](https://brambrinkmeier.com/entra/aadsts/51004/), [AADSTS500021](https://brambrinkmeier.com/entra/aadsts/500021/), [AADSTS500200](https://brambrinkmeier.com/entra/aadsts/500200/), [AADSTS500571](https://brambrinkmeier.com/entra/aadsts/500571/), [AADSTS5000211](https://brambrinkmeier.com/entra/aadsts/5000211/), [AADSTS9002331](https://brambrinkmeier.com/entra/aadsts/9002331/), [AADSTS9002346](https://brambrinkmeier.com/entra/aadsts/9002346/)

## License and citation

CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). CC BY 4.0 covers the author's own text and classification fields. Quoted Microsoft error wording belongs to Microsoft, is quoted with its source and can change.

Cite as: Bram Brinkmeier, "AADSTS50020: Account from identity provider not in tenant", https://brambrinkmeier.com/entra/aadsts/50020/ (CC BY 4.0), last updated 2026-10-25.
