-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[Bug] ArgumentNullException when HomeAccountId is null and acquiring OBO token #4670
Comments
MSAL cannot cache user tokens without an account id. The account id is derived from the client_info (home oid + home tid) or, if this is not present, from the IdToken's sub claim. MSAL always asks for an ID Token and as per OIDC spec, the So the correct behavior is for MSAL to fail with an exception if the account ID is null and we're in OBO scenrio (denoted by API_ID for example). Code should go in TokenCache's SaveMsalResponse. Exception message should be "No account ID can be inferred from the STS response. In OBO scenarios, this can happen if the OBO call targets a tenant which is different than the tenant from the client token (the Note: we have confirmed with ESTS that this behavior can occur with OBO for SP. |
Hi @bgavrilMS , thanks for the information. Does that mean MSAL currently cannot support SPN OBO for cross tenant scenario? |
Yes @Frey-Wang, SPN OBO for cross-tenant is not supported by neither ESTS nor MSAL |
@bgavrilMS, I found this post to support SPN OBO: #1845. So is it supposed for first party app to use the same tenant id as the SPN to generate this token since it only supports single tenant scenario (even though the first party app has a different tenant id)? |
@Frey-Wang - SPN OBO is currently used by a handful of 1st party applications and must be enabled manually by the STS team. It is not supported to 3p - but this is on the backlog to be productized at some point. Single tenant scenario only is needed - client app and web api must target the same tenant id. |
Got it. Thanks for the clarification! |
Library version used
4.59.0
.NET version
All platform
Scenario
ConfidentialClient - web api (AcquireTokenOnBehalfOf)
Is this a new or an existing app?
This is a new app or experiment
Issue description and reproduction steps
When acquiring OBO tokens and the HomeAccountId is null, we'll receive this exception:
According to public document this property can be null, thus the library should handle the null case: https://learn.microsoft.com/en-us/dotnet/api/microsoft.identity.client.iaccount.homeaccountid?view=msal-dotnet-latest
Relevant code snippets
No response
Expected behavior
No response
Identity provider
Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)
Regression
No response
Solution and workarounds
No response
The text was updated successfully, but these errors were encountered: