如何使用Azure API管理REST API从订阅密钥获取用户?
在Azure API管理上,我想使用从代理传递到服务的订阅密钥来标识调用背后的用户 我能找到的唯一解决方案是获取primaryKey或secondaryKey上的所有子描述和过滤器,以最终找到使用此REST API的用户,但这将太长,因为我将有很多订阅 当我激活跟踪以查看Echo API上的API管理如何处理消息时,我可以看到代理可以识别用户和产品: { "timestamp":"2014-08-19T15:20:06.7804622Z", "source":"request handler", "data":{ "configuration":{ "api":{ "from":"echo", "to":"http://echoapi.cloudapp.net/api" }, "operation":{ "method":"GET", "uriTemplate":"/resource" }, "user":{ "id":1, "groups":[ ] }, "product":{ "id":3 } } } }, { “时间戳”:“2014-08-19T15:20:06.780462Z”, “源”:“请求处理程序”, “数据”:{ “配置”:{ “api”:{ “from”:“echo”, “至”:http://echoapi.cloudapp.net/api" }, “操作”:{ “方法”:“获取”, “uriTemplate”:“/资源” }, “用户”:{ “id”:1, “团体”:[ ] }, “产品”:{ “id”:3 } } } }, 我想在服务端获取此信息以识别用户 您能否告诉我是否可以使用Azure API管理REST API从订阅密钥获取用户 谢谢如何使用Azure API管理REST API从订阅密钥获取用户?,rest,azure-api-management,Rest,Azure Api Management,在Azure API管理上,我想使用从代理传递到服务的订阅密钥来标识调用背后的用户 我能找到的唯一解决方案是获取primaryKey或secondaryKey上的所有子描述和过滤器,以最终找到使用此REST API的用户,但这将太长,因为我将有很多订阅 当我激活跟踪以查看Echo API上的API管理如何处理消息时,我可以看到代理可以识别用户和产品: { "timestamp":"2014-08-19T15:20:06.7804622Z", "source":"request
Johnny请参考MSDN上的讨论您可以使用策略为每个请求检索有关用户的信息。这位于API发布者门户的
/Admin/Policies/
中
<policies>
<inbound>
<set-header name="request-email" exists-action="override">
<value>@(context.User.Email)</value>
</set-header>
<set-header name="request-id" exists-action="override">
<value>@(context.User.Id)</value>
</set-header>
</inbound>
<backend>
<forward-request />
</backend>
<outbound />
@(context.User.Email)
@(context.User.Id)
有关使用变量设置标题的更多信息,请参阅