Reputation: 28500
How can I add a proxy to an AcquireToken
method?
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();
}
When this is run it's yellow-screening with:
The remote server returned an error: (407) Proxy Authentication Required.
However, there doesn't seem to be any way I can add proxy information to the AuthenticationContext
the method.
Upvotes: 0
Views: 326
Reputation: 26324
You should do that in web.config
instead.
<configuration>
<system.net>
<defaultProxy>
<proxy
usesystemdefault="true"
proxyaddress="http://user:[email protected]:3128"
bypassonlocal="true"
/>
<bypasslist>
<add address="[a-z]+\.contoso\.com" />
</bypasslist>
</defaultProxy>
</system.net>
</configuration>
(from the .NET docs)
Upvotes: 1