我遇到了一个问题,即在从客户端应用程序通过 Azure Active Directory 应用程序代理到 REST Web 服务的 HTTP 请求中缺少带有承载令牌的授权标头。
Web 服务托管在本地,客户端应用程序使用 Azure AD 应用程序代理 URL 从 Internet 使用,并且请求已针对 ADFS 进行身份验证。身份验证标头是在向 Azure AD 应用程序代理 URL 发送请求时添加的,我猜它已被代理连接器删除。
请在下面找到请求内容和帮助。如何在对应用程序代理的原始请求中包含 Authenticator 标头?
GET /TimelogSvc/rest/Timelog/GetTimeLog?EmailId=John@BizNext.com.sg&Fromdate=2019-04-21&Todate=2019-04-27 HTTP/1.1
Connection: Keep-Alive
Host: agileuat.BizNext.com.sg
X-Forwarded-For: 203.126.130.140
X-MS-Proxy: AzureAD-Application-Proxy
OS-Host: agileuat.BizNext.com.sg
OS-Path: /TimelogSvc
OS-Pta: /rest/Timelog
OS-Page: /GetTimeLog?EmailId=John08@BizNext.com.sg&Fromdate=2019-04-21&Todate=2019-04-27
另请参阅下面的客户代码。
AuthenticationContext authContext = new AuthenticationContext(authority + tenantID);
HttpClient httpClient = new HttpClient();
string s = string.Empty;
result = await authContext.AcquireTokenAsync(resourceUri, clientId, new Uri(redirectUri), new PlatformParameters(PromptBehavior.Auto));
// Append the token as bearer in the request header.
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", result.AccessToken);
// Call the API.
HttpResponseMessage response = await httpClient.GetAsync("https://timelogapitest-BizNext.msappproxy.net/TimelogSvc/rest/Timelog/GetTimeLog?EmailId=John@bizNext.com.sg&Fromdate=2019-04-21&Todate=2019-04-27");
s = await response.Content.ReadAsStringAsync();