How to change value of the audience claim in access token

mihael.safaric 1 Reputation point
2021-03-10T16:07:56.863+00:00

Hi,

we are creating a flow in Azure AD B2C by using custom policies. By default, access_token contains an audience claim (named aud) which has the value set to the application ID.

We would like to change that value by attaching an additional string to it, ie. aud="applicationID OUR_CUSTOM_ID".

In order to achieve that, we would need to read the aud claim value in the custom policy and then set the aud claim to a new value.
We haven't been successful with neither of those two things, so the questions are:

  • how to set a new value to the aud claim for the access token?
  • how to read the value of the aud claim from the access token?

Thanks.

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,652 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jas Suri 91 Reputation points Microsoft Employee
    2021-03-19T09:45:53.873+00:00

    The only way I can see this being resolved, but not optimally is as follows:

    In the relyingParty section, add the aud claim yourself with a defaultValue.

    xml
    <OutputClaim ClaimTypeReferenceId="aud" DefaultValue="applicationID OUR_CUSTOM_ID"  AlwaysUseDefaultValue="true"/>
    

    Downside is that the Relying party is fixed regardless of the clientId used in the auth request.

    1 person found this answer helpful.