`AcquireTokenAsync`返回407

时间:2018-01-29 17:56:02

标签: .net azure oauth-2.0 azure-active-directory

如何向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方法中。

1 个答案:

答案 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