open oauth login screen through corporate proxy

420
3
10-28-2021 11:31 PM
Mannus_Etten
New Contributor III

I have implemented this sample in my WPF .net5 application:
https://developers.arcgis.com/net/forms/sample-code/authenticate-with-oauth/

That works till so far perfectly. But, now I have a client who uses a corporate proxy to go to the internet.
So opening the arcgis online login screen fails.

No connection could be made because the target machine actively refused it. (xxx.maps.arcgis.com:443)
---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.

Same portal shows the login screen on a machine without a corporate proxy.
Under the hoods the API probably uses the httpclient/webclient which has a Proxy-property.

How I can let this sample work through the corporate proxy and not an arcgis-proxy.

CEO the Right Direction BV/Portal Genius
Tags (3)
0 Kudos
3 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

The method you assign to the AuthenticationManager ChallengeHandler should be raised when encountering a 407 Proxy Authentication Required response, allowing you to create and set the required proxy credential. Or alternatively you can do this upfront by creating the credential and adding to the Authentication Manager. 

In the sample you referenced, you would add additional logic in the `PromptCredentialAsync` method, for example:

if (requestInfo.AuthenticationType == AuthenticationType.Token)
{
    credential = await AuthenticationManager.Current.GenerateCredentialAsync(info.ServiceUri);
}
else if (requestInfo.AuthenticationType == AuthenticationType.Proxy)
{
    credential =  new ProxyCredential(info.ProxyServiceUri, "Basic", new System.Net.NetworkCredential("...", "..."));
}

 

Also see https://developers.arcgis.com/net/api-reference/api/netwin/Esri.ArcGISRuntime/Esri.ArcGISRuntime.Sec...

 

0 Kudos
Mannus_Etten
New Contributor III

hi Michael,

 

okay, how does the requestInfo know it is AuthenticationType.Proxy?

Does this not apply to the Arcgis Proxy-services?

My question is not about those proxy-services. My proxy is the one you define in the browser for internet access.

CEO the Right Direction BV/Portal Genius
0 Kudos
MichaelBranscomb
Esri Frequent Contributor

This only applies to standard proxy servers, the ArcGIS resource proxy is not supported. 

0 Kudos