是否可以在AWS Lambda函数中为HttpClient
指定Windows凭据?
例如:
var handler = new HttpClientHandler {
Credentials = new NetworkCredential("username", "password", "domain")
};
var httpClient = new HttpClient(handler);
var content = new StringContent("<test>test</test>", Encoding.UTF8, "application/xml");
var response = await httpClient.PostAsync("http://someurl", "content");
目标url返回401 Unauthorized
,看起来NetworkCredentials
尚未通过。
Lambda已被授予角色AWSLambdaFullAccess
。
在本地执行时,具有相同凭据的此代码可以按预期工作。