mugzi
mugzi

Reputation: 829

How to get user details using subscription key (primary /secondary) in azure api management?

In the APIM's Developer portal, developers can get their own subscription key. Further developers can use API service by adding this subscription key to the header information of the http. However I didn't find a way to identify actual user by this subscription key. Therefore I want to know a way to identify user through subscription key.

Please help me to find an answer

Upvotes: 1

Views: 1545

Answers (1)

4c74356b41
4c74356b41

Reputation: 72151

For example, if you want to set the user of the developer into the header of the request, you would add the following to the APIM policy:

<set-header name="user" exists-action="override">
    <value>@{var usr = context.User;
    return usr.Email;}</value>
</set-header>

So, you need to get it from the context.User. https://learn.microsoft.com/en-us/azure/api-management/api-management-policy-expressions#a-namepolicyexpressionsexamplesa-examples

Upvotes: 1

Related Questions