“A required Metadata item with key \””ClientId\”” was not found in the TechnicalProfile with id …” error in Azure AD B2C
I was creating a custom policy when I got this error:
A quick look at AppInsights and I see:
""Exception"": {
""Kind"": ""Handled"",
""HResult"": ""80131500"",
""Message"": ""A required Metadata item with key \""ClientId\"" was not
found in the TechnicalProfile with id \""AAD-UserReadUsingEmailAddress\""
in policy \""..."" of tenant \""tenant.onmicrosoft.com\""."",
""Data"": {
""IsPolicySpecificError"": true,
...
WTF! There is no clientID in UserRead? And Mr. Google had nothing to offer 😢
So I did a bit of poking around and realised that one of the attributes that I was reading was an extension attribute. Which rang a bell …
As per the docs, you need to configure this:
<TechnicalProfile Id="AAD-Common">
<Metadata>
<!--Insert b2c-extensions-app application ID here, for example: 11111111-1111-1111-1111-111111111111-->
<Item Key="ClientId"></Item>
<!--Insert b2c-extensions-app application ObjectId here, for example: 22222222-2222-2222-2222-222222222222-->
<Item Key="ApplicationObjectId"></Item>
</Metadata>
</TechnicalProfile>
So when I tried to read the extension attribute, the clientID it referred to was the one in the AAD-Common technical profile. A somewhat misleading error message!
All good!