0
votes

I have created an AAD B2C custom policy which makes a call to call our REST API when a new user signs up by creating a custom Azure AD B2C custom policy.But i have to set two values to REST API. Ocp-Apim-Subscription-Key in header and email id in body.but i have to set SendClaimsIn only as either header or body. so i added SendClaimsIn as header.But i cdont know how to set both values as inputclaim.My code is

<ClaimsProvider>
  <DisplayName>Signup REST APIs</DisplayName>
  <TechnicalProfiles>
    <TechnicalProfile Id="REST-ValidateProfile">
      <DisplayName>Check loyaltyId Azure Function web hook</DisplayName>
      <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.RestfulProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
      <Metadata>
        <Item Key="ServiceUrl">https://myapicall.io/api/</Item>
        <Item Key="SendClaimsIn">Header</Item>
        <Item Key="AuthenticationType">Bearer</Item>
        <Item Key="AllowInsecureAuthInProduction">false</Item>
      </Metadata>
      <CryptographicKeys>
        <Key Id="BearerAuthenticationToken" StorageReferenceId="B2C_1A_RestApiBearerToken" />
      </CryptographicKeys>
      <InputClaims>
        <!-- Claims sent to your REST API -->
        <InputClaim ClaimTypeReferenceId="email" />
        <InputClaim ClaimTypeReferenceId="grant_type"  "DefaultValue"="Ocp-Apim-Subscription-Key"/>
      </InputClaims>
      <UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
    </TechnicalProfile>
  </TechnicalProfiles>
</ClaimsProvider> 

its shows validation error while uploading

makes a reference to ClaimType with id "Ocp-Apim-Subscription-Key" but neither the policy nor any of its base policies contain such an element

i want to set header as Ocp-Apim-Subscription-Key as "12345"

1

1 Answers

1
votes

Add the following inside of the <ClaimsSchema> tag near the top of the file:

<ClaimType Id="Ocp-Apim-Subscription-Key">
  <DisplayName>OCP APIM Subscription Key</DisplayName>
  <DataType>string</DataType>
</ClaimType>

Change the values inside of the <InputClaims> in your REST-ValidateProfile technical profile to the following:

<InputClaims>
  <!-- Claims sent to your REST API -->
  <InputClaim ClaimTypeReferenceId="email" />
  <InputClaim ClaimTypeReferenceId="Ocp-Apim-Subscription-Key" DefaultValue="12345" />
</InputClaims>

You don't need a grant_type input claim for a static OAuth2 bearer (see here).