<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to display WFS layer with authentication (login/password)? in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-display-wfs-layer-with-authentication-login/m-p/1003643#M9582</link>
    <description>&lt;P data-unlink="true"&gt;Hello&amp;nbsp;&lt;SPAN class="UserName lia-user-name lia-user-rank-New-Contributor-III lia-component-message-view-widget-author-username"&gt;&lt;SPAN class=""&gt;Jean-Christophe,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-New-Contributor-III lia-component-message-view-widget-author-username"&gt;&lt;SPAN class=""&gt;My assumption is that the credential is not getting applied to the GetCapabilities url.&amp;nbsp;Maybe try adding another Credential and let the serviceUri be the GetCapabilities url.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-New-Contributor-III lia-component-message-view-widget-author-username"&gt;&lt;SPAN class=""&gt;I hope this works.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-New-Contributor-III lia-component-message-view-widget-author-username"&gt;&lt;SPAN class=""&gt;Thanks,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-New-Contributor-III lia-component-message-view-widget-author-username"&gt;&lt;SPAN class=""&gt;Aditya&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Nov 2020 21:28:13 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2020-11-20T21:28:13Z</dc:date>
    <item>
      <title>How to display WFS layer with authentication (login/password)?</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-display-wfs-layer-with-authentication-login/m-p/1002526#M9572</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I would like to use a WFS layer like in this example: &lt;A href="https://developers.arcgis.com/net/latest/wpf/sample-code/display-wfs-layer/" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/net/latest/wpf/sample-code/display-wfs-layer/&lt;/A&gt;&lt;BR /&gt;but my wfs service requires a login + password authentication and i have no idea how to implement this authentication.&lt;BR /&gt;So how to do?&lt;BR /&gt;Thanks in advance for all the answers&lt;/P&gt;&lt;P&gt;Cordialement,&lt;/P&gt;&lt;P&gt;Jean-Christophe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 13:58:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-display-wfs-layer-with-authentication-login/m-p/1002526#M9572</guid>
      <dc:creator>Jean-ChristopheBertolini</dc:creator>
      <dc:date>2020-11-18T13:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to display WFS layer with authentication (login/password)?</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-display-wfs-layer-with-authentication-login/m-p/1003063#M9577</link>
      <description>&lt;P&gt;Hi Jean-Cristophe. I recommend looking at our &lt;A href="https://developers.arcgis.com/net/latest/wpf/sample-code/authenticate-with-oauth/" target="_self"&gt;security samples&lt;/A&gt; for help with authentication workflows. Can you please share information about what type of authentication you're using for your WFS layer?&lt;/P&gt;&lt;P&gt;Zack&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 18:29:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-display-wfs-layer-with-authentication-login/m-p/1003063#M9577</guid>
      <dc:creator>ZackAllen</dc:creator>
      <dc:date>2020-11-19T18:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to display WFS layer with authentication (login/password)?</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-display-wfs-layer-with-authentication-login/m-p/1003101#M9579</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;In this particular scenario, I would suggest going through Zack's recommendation first to see if that answers your questions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If you have already tried adding a NetworkCredential&lt;/SPAN&gt; with username/password and still the server denies access (does not challenge the client for username/password). I would also suggest trying out the following code if your server implements a HTTP Basic authentication.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private void EagerlyAddNetworkCredentials(object sender, HttpRequestMessage e)
{
    var anyCred = Esri.ArcGISRuntime.Security.AuthenticationManager.Current.FindCredential(e.RequestUri, AuthenticationType.NetworkCredential);
    if (anyCred is ArcGISNetworkCredential runtimeNetCred)
    {
        // If a NetworkCredential is found for this request, but we are still waiting to be challenged...
        if (!e.Headers.Contains("Authorization"))
        {
            // Generate an HTTP Basic Authorization header per RFC 2617
            var netCred = runtimeNetCred.Credentials.GetCredential(e.RequestUri, "Basic");
            var rawCredentialBytes = Encoding.GetEncoding("ISO-8859-1").GetBytes($"{netCred.UserName}:{netCred.Password}");

            // Add it to the request
            e.Headers.Add("Authorization", $"Basic {Convert.ToBase64String(rawCredentialBytes)}");
        }
    }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

//Loads the service
private async void WFSNetworkCred()
{
    ArcGISHttpClientHandler.HttpRequestBegin += EagerlyAddNetworkCredentials;

    MyView.Map = new Map(Basemap.CreateImagery());
    var am = Esri.ArcGISRuntime.Security.AuthenticationManager.Current;
    am.AddCredential(new ArcGISNetworkCredential
    {
        ServiceUri = new Uri("Insert_Service_URL_Here"),
        Credentials = new NetworkCredential("username", "password"),
    });

    var wfs = "Insert_Service_URL_Here";
    var wfsService = new WfsService(new Uri(wfs));
    await wfsService.LoadAsync();
} ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I protected a local GeoServer service with a username and password. &lt;FONT&gt;S&lt;SPAN&gt;ome OGC services do not challenge the clients to log in. The service needs an `Authentication` header present in the request (for ex. Basic authentication header). This scenario forces the clients to `eagerly` send their login info with the request itself and not wait for the challenge to come back.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This is currently not supported in the Runtime SDK. However, a possible workaround could be to tap into the&amp;nbsp;&lt;A title="https://developers.arcgis.com/net/latest/wpf/api-reference/html/E_Esri_ArcGISRuntime_Http_ArcGISHttpClientHandler_HttpRequestBegin.htm" href="https://developers.arcgis.com/net/latest/wpf/api-reference/html/E_Esri_ArcGISRuntime_Http_ArcGISHttpClientHandler_HttpRequestBegin.htm" target="_blank" rel="noopener"&gt;ArcGISHttpClientHandler.HttpRequestBegin Event&lt;/A&gt;, forcing it to add our NetworkCredentials with the outgoing requests (like in the code above).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I hope this works for you. Let me know if you face any problems.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 19:18:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-display-wfs-layer-with-authentication-login/m-p/1003101#M9579</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-11-19T19:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to display WFS layer with authentication (login/password)?</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-display-wfs-layer-with-authentication-login/m-p/1003439#M9581</link>
      <description>&lt;P&gt;Hello Aditya,&lt;/P&gt;&lt;P&gt;Thank you for your useful answer. It seens to work for the network credential.&lt;/P&gt;&lt;P&gt;But i get an other error when opening layer : "Invalid XML.: Parser was expecting WFS_Capabilities."&lt;/P&gt;&lt;P&gt;Could you help me again ?&lt;/P&gt;&lt;P&gt;This is my code (with some confidential information masked) :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private async void Initialize()
{
ArcGISHttpClientHandler.HttpRequestBegin += EagerlyAddNetworkCredentials;

// Create the map with topographic basemap.
MyMapView.Map = new Map(Basemap.CreateTopographic());

try
{
var am = Esri.ArcGISRuntime.Security.AuthenticationManager.Current;
am.AddCredential(new ArcGISNetworkCredential
{
ServiceUri = new Uri("http://x.y.z.1/cgi-bin/mapservRLV.exe?map=D:/GFI/Cartes/client1/Carte4_IA.map"),
Credentials = new NetworkCredential("toto", "titi"),
});

var wfs = "http://x.y.z.1/cgi-bin/mapservRLV.exe?map=D:/GFI/Cartes/client1/Carte4_IA.map&amp;amp;service=WFS&amp;amp;request=GetCapabilities&amp;amp;version=1.1.0";
var wfsService = new Esri.ArcGISRuntime.Ogc.WfsService(new Uri(wfs));
await wfsService.LoadAsync();

...


}
catch (Exception e)
{
MessageBox.Show(e.ToString(), "Couldn't load sample.");
Debug.WriteLine(e);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I forget to say that the request with GetCapabilities works in the browser.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2020 14:55:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-display-wfs-layer-with-authentication-login/m-p/1003439#M9581</guid>
      <dc:creator>Jean-ChristopheBertolini</dc:creator>
      <dc:date>2020-11-20T14:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to display WFS layer with authentication (login/password)?</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-display-wfs-layer-with-authentication-login/m-p/1003643#M9582</link>
      <description>&lt;P data-unlink="true"&gt;Hello&amp;nbsp;&lt;SPAN class="UserName lia-user-name lia-user-rank-New-Contributor-III lia-component-message-view-widget-author-username"&gt;&lt;SPAN class=""&gt;Jean-Christophe,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-New-Contributor-III lia-component-message-view-widget-author-username"&gt;&lt;SPAN class=""&gt;My assumption is that the credential is not getting applied to the GetCapabilities url.&amp;nbsp;Maybe try adding another Credential and let the serviceUri be the GetCapabilities url.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-New-Contributor-III lia-component-message-view-widget-author-username"&gt;&lt;SPAN class=""&gt;I hope this works.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-New-Contributor-III lia-component-message-view-widget-author-username"&gt;&lt;SPAN class=""&gt;Thanks,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-New-Contributor-III lia-component-message-view-widget-author-username"&gt;&lt;SPAN class=""&gt;Aditya&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2020 21:28:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-display-wfs-layer-with-authentication-login/m-p/1003643#M9582</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-11-20T21:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to display WFS layer with authentication (login/password)?</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-display-wfs-layer-with-authentication-login/m-p/1005053#M9590</link>
      <description>&lt;P&gt;Hello Zack,&lt;/P&gt;&lt;P&gt;Authentication type should be Basic :&amp;nbsp;WWW-Authenticate: Basic realm="mapservRLV"&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;jcb&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2020 16:55:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-display-wfs-layer-with-authentication-login/m-p/1005053#M9590</guid>
      <dc:creator>Jean-ChristopheBertolini</dc:creator>
      <dc:date>2020-11-26T16:55:11Z</dc:date>
    </item>
  </channel>
</rss>

