I use UserIsNew attribute for my Azure B2C user flow. Users log in with Angular app and I get this attribute/claim on the front-end. Also, I get an access token which is used as a bearer to access ASP.NET Core 3.1 web API.
And here's the problem - the access token works (contains the UserIsNew claim) when the user is Local (Email signup). But when it's an external user (Microsoft account in my case) I get the claim in the Angular app only. The access token does not have the custom attribute, thus web API returns access denied!
What am I missing?
UPDATE
These are the claims I'm getting in the angular app:
And these are from server side (web API):
"claims": [
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"type": "exp",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"type": "nbf",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"type": "aud",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {
"http://schemas.xmlsoap.org/ws/2005/05/identity/claimproperties/ShortTypeName": "idp"
},
"type": "http://schemas.microsoft.com/identity/claims/identityprovider",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"type": "name",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {
"http://schemas.xmlsoap.org/ws/2005/05/identity/claimproperties/ShortTypeName": "oid"
},
"type": "http://schemas.microsoft.com/identity/claims/objectidentifier",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {
"http://schemas.xmlsoap.org/ws/2005/05/identity/claimproperties/ShortTypeName": "sub"
},
"type": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {
"http://schemas.xmlsoap.org/ws/2005/05/identity/claimproperties/ShortTypeName": "given_name"
},
"type": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {
"http://schemas.xmlsoap.org/ws/2005/05/identity/claimproperties/ShortTypeName": "family_name"
},
"type": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {},
"type": "emails",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {},
"type": "tfp",
"value": "B2C_1_susi",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {},
"type": "nonce",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {
"http://schemas.xmlsoap.org/ws/2005/05/identity/claimproperties/ShortTypeName": "scp"
},
"type": "http://schemas.microsoft.com/identity/claims/scope",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {},
"type": "azp",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {},
"type": "ver",
},
{
"issuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"originalIssuer": "https://[mytenant].b2clogin.com/[guid]/v2.0/",
"properties": {},
"type": "iat",
}
],
newUser is missing.
UPDATE 1
These are used flow User Attributes set up:
And this is App Claims set up:
Also, keep in mind - I'm testing the scenario when the user signs up, so UserIsNew is expected every time.


