Thank you for reaching out on Microsoft Q&A.
I understand that after adding the optional claim (user.onpremisessamaccountname) to your application, the authentication process is failing with the error AADSTS50146.
This error occurs because the application is receiving a token with customized claims, but it has not been configured to accept these modifications. By default, Microsoft Entra ID ensures that tokens remain unchanged and securely signed. If claims are modified, the application must explicitly acknowledge them to prevent security risks.
As outlined in documentation, there are two ways to resolve this issue:
- Configure a custom signing key (typically for multi-tenant applications).
- Update the application manifest to accept mapped claims (for single-tenant applications).
Since your application is single tenant, setting "acceptMappedClaims": true
in the manifest is the correct approach. However, I see that you are encountering same error:
AADSTS501461: AcceptMappedClaims is only supported for a token audience matching the application GUID or an audience within the tenant's verified domains.
Given that you have already added and verified the required domain, please double-check the following:
- Ensure the domain is properly verified in the Custom domain names section of your Microsoft Entra ID tenant.
- Confirm that the Application ID URI is correctly set to use a verified domain name of your Microsoft Entra tenant (e.g.,
https://yourdomain/my-api
)
Hope this helps. Do let us know if you any further queries.