【发布时间】:2017-06-11 13:20:20
【问题描述】:
在 Microsoft oData v4 代理客户端中,有一个选项可以将身份验证令牌添加到每个请求中。可以通过以下方式实现:
var container = new Default.Container(new Uri(http://localhost:9000/));
//Registering the handle to the BuildingRequest event.
container.BuildingRequest += (sender, e) => OnBuildingRequest(sender, e, accessToken);
//Every time a OData request is build it adds an Authorization Header with the acesstoken
private static void OnBuildingRequest(object sender, BuildingRequestEventArgs e, TokenResponse token)
{
e.Headers.Add("Authorization", "Bearer " + token.AccessToken);
}
如何使用简单的 odata 客户端做同样的事情?
【问题讨论】:
标签: c# oauth-2.0 access-token auth-token simple.odata.client