B2C pass custom header to REST API

Vikas Tiwari 766 Reputation points
2020-08-12T15:39:43.57+00:00

Hi @AmanpreetSingh-MSFT ,

Could you please help me to find documentation or sample custom profile example where I can find way to pass custom header to REST API?

In my case we are calling REST API to validate user credentials and REST API is secured through API key, in order to make successful calls I need to pass following header:

"X-API-Key" : "API KEY VALUE"

Another details I wanted to check if there is anyway to automate this behavior, for example: If I store my API key in key-vault can I get it from key vault and add it into custom policy header, so that key rotation scenario will be handled automatically?

Thanks for your help.

Thanks for your help.

Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,851 questions
0 comments No comments
{count} votes

Accepted answer
  1. AmanpreetSingh-MSFT 56,561 Reputation points
    2020-08-19T05:32:47.27+00:00

    Hi @Vikas Tiwari ·

    Please refer to the example below:

    <TechnicalProfile Id="RestApi">  
        <DisplayName>Restful Open Source Claims Provider</DisplayName>  
        <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.RestfulProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />  
        <Metadata>  
            <Item Key="ServiceUrl">http://myapi.example.com/api/User/formbody</Item>  
            <Item Key="AuthenticationType">ApiKeyHeader</Item>  
        </Metadata>  
        <CryptographicKeys>  
            <Key Id="x-api-key" StorageReferenceId="KeyIdInStorage" />  
        </CryptographicKeys>  
    </TechnicalProfile>  
    

    The key here is "AuthenticationType" and the CryptographicKey Id= which sets the header key. Let me know if it helps.

    -----------------------------------------------------------------------------------------------------------

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. 2020-08-12T17:28:08.647+00:00

    You can send all the input claims as headers setting the Metadata\SendClaimsIn element value to Header.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.