【问题标题】:`AcquireTokenAsync` returns 407`AcquireTokenAsync` 返回 407
【发布时间】:2018-01-30 17:55:25
【问题描述】:

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

【问题讨论】:

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


    【解决方案1】:

    您应该改为在 web.config 中执行此操作。

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

    (来自.NET docs

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-28
      • 2019-09-08
      • 2019-07-26
      • 2019-08-10
      • 1970-01-01
      • 2014-09-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多