如何向AcquireToken
方法添加代理?
public async Task<ActionResult> Index()
{
const string AUTHORITY_URL =
@"https://login.microsoftonline.com/{tenancy ID}/oauth2/authorize";
const string RESOURCE_URL = @"https://analysis.windows.net/powerbi/api";
const string CLIENT_ID = @"{Client ID}";
var credential = new UserPasswordCredential("username", "password");
var authenticationContext = new AuthenticationContext(AUTHORITY_URL);
var authenticationResult = await authenticationContext.AcquireTokenAsync(RESOURCE_URL, CLIENT_ID, credential);
return View();
}
当它运行时,它会进行黄色筛选:
The remote server returned an error: (407) Proxy Authentication Required.
但是,似乎没有任何方法可以将代理信息添加到AuthenticationContext
方法中。
答案 0 :(得分:1)
你应该在<configuration>
<system.net>
<defaultProxy>
<proxy
usesystemdefault="true"
proxyaddress="http://user:pass@192.168.1.10:3128"
bypassonlocal="true"
/>
<bypasslist>
<add address="[a-z]+\.contoso\.com" />
</bypasslist>
</defaultProxy>
</system.net>
</configuration>
代替。
iris
(来自line 1046)