Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to populate a string collection from a REST API response

Tags:

azure-ad-b2c

How can I populate a StringCollection from a REST API call in an Azure AD B2C custom policy?

My Rest API is returning this as its ResponseContent

class ResponseContent {
    public string version;
    public int status;
    public string[] strings;
}


new ResponseContent
{
    version = "1.0.0",
    status = (int) HttpStatusCode.OK,
    strings= new [] { "str1", "str2", "str3", "str4", "str5"}
},

The technical profile executes as expected but when it populates the StringCollection shows in the claims bag via the Journey Recorder as a list of strings

When I try and show these as a dropdown list in a self-asserted page the list is empty.

Is this possible to do this and if so how?

Here is my claim definition, as you can see no Enumeration

<ClaimType Id="strings">
    <DisplayName>Strings to be populated from REST Service </DisplayName>
    <DataType>stringCollection</DataType>
    <AdminHelpText>blah.</AdminHelpText>
    <UserHelpText>blah.</UserHelpText>
    <UserInputType>DropdownSingleSelect</UserInputType>
</ClaimType>

<!-- here is the technical profile that i am using to populate the claims from it -->

</TechnicalProfile>
<TechnicalProfile Id="Populate-strings-from-app">
    <DisplayName>Populate-Strings</DisplayName>
    <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.RestfulProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
    <Metadata>
        <Item Key="AuthenticationType">None</Item>
        <Item Key="ServiceUrl">XXXXXXXX</Item>
        <Item Key="SendClaimsIn">QueryString</Item>
    </Metadata>
    <InputClaims>
        <InputClaim ClaimTypeReferenceId="client_id" PartnerClaimType="client_id" DefaultValue="{OIDC:ClientId}" />
    </InputClaims>
    <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="strings" />
    </OutputClaims>
</TechnicalProfile>

In the claims bag I can see it is showing as a generic list which means I think i should be doing a transformation on it but i dont know if i have ever seen a dynamic transformation on a list without knowing what every element is

like image 751
whatisthejava Avatar asked Oct 30 '22 01:10

whatisthejava


1 Answers

This is unfortunately not supported today :-( The only way to populate the enumeration is by providing a list of values in the policy.

I would recommend adding this as a suggestion on the Azure AD B2C feedback page for Azure AD (or vote for one if it already exists).

like image 192
Omer Iqbal Avatar answered Nov 09 '22 05:11

Omer Iqbal