<?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: Challenge Handler not called in WPF in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/challenge-handler-not-called-in-wpf/m-p/1199288#M11209</link>
    <description>&lt;P&gt;Alright, thank your for this extra information!&amp;nbsp; I think I know what's going on.&lt;/P&gt;&lt;P&gt;Setting a global APIKey is meant to be an &lt;EM&gt;alternative&lt;/EM&gt; to making users log into the app.&amp;nbsp; It is &lt;A href="https://developers.arcgis.com/documentation/mapping-apis-and-services/security/#authentication-methods" target="_self"&gt;one of three ways to add an access token&lt;/A&gt; to app's network requests.&amp;nbsp; Mixing multiple token sources in one application can lead to problems.&amp;nbsp; What I think is happening in your case is -- having the API key set means that every request to arcgis.com already has an access token, which interferes with credential-challenge detection and can even prevent a TokenCredential from being used.&lt;/P&gt;&lt;P&gt;If your app will always require users to log in, then you probably don't need to use that API key.&amp;nbsp; See if removing the APIKey allows the ChallengeHandler and/or TokenCredential to work.&lt;/P&gt;&lt;P&gt;But if your app needs to have logging in optional -- e.g. by switching from API key to named-used authentication mid-flight -- that will be tricky.&amp;nbsp; That's not really a scenario we've tested so far, and I'd be curious to learn more about your use case.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Aug 2022 06:28:50 GMT</pubDate>
    <dc:creator>MatveiStefarov</dc:creator>
    <dc:date>2022-08-04T06:28:50Z</dc:date>
    <item>
      <title>Challenge Handler not called in WPF</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/challenge-handler-not-called-in-wpf/m-p/1195466#M11163</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Am seeing some really odd behavior with Windows and authentication.&amp;nbsp; I have code that works fine in Xamarin forms on iOS.&amp;nbsp; Very simple, just setting up Authentication.&amp;nbsp; What I am seeing though is that in WPF (both Win standard and NET6) the challenge handler does not get called.&amp;nbsp; It just does not go into the method, and then I get an unauthorized error trying to open the item.&amp;nbsp; As I said, the same code works in Xamarin Forms, I can look at the AuthenticationManager and see a registered method for the challenge handler, but it does not enter the method.&lt;/P&gt;&lt;P&gt;Any thoughts on something additional needed in WPF.&amp;nbsp; I have gone through the samples and do not see anything being done that differs&lt;/P&gt;&lt;P&gt;Thanks - Joe&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 16:31:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/challenge-handler-not-called-in-wpf/m-p/1195466#M11163</guid>
      <dc:creator>JoeHershman</dc:creator>
      <dc:date>2022-07-25T16:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: Challenge Handler not called in WPF</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/challenge-handler-not-called-in-wpf/m-p/1198376#M11200</link>
      <description>&lt;P&gt;Hello!&amp;nbsp; I am investigating this issue and trying to narrow down possible causes.&amp;nbsp; I have a couple questions for you.&lt;/P&gt;&lt;P&gt;Does your WPF application have a global APIKey (i.e. &lt;STRONG&gt;ArcGISRuntimeEnvironment.ApiKey&lt;/STRONG&gt; property is set to some non-empty value)?&amp;nbsp; How about the Xamarin apps?&lt;/P&gt;&lt;P&gt;Have you tried generating a token ahead of time, using &lt;STRONG&gt;AuthenticationManager.Current.GenerateCredentialAsync(...)&lt;/STRONG&gt; followed by &lt;STRONG&gt;AuthenticationManager.Current.AddCredential(...)&lt;/STRONG&gt;?&amp;nbsp; This is a possible workaround for challenge-detection issues, if you know the server/username/password combination ahead of time.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 06:09:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/challenge-handler-not-called-in-wpf/m-p/1198376#M11200</guid>
      <dc:creator>MatveiStefarov</dc:creator>
      <dc:date>2022-08-02T06:09:46Z</dc:date>
    </item>
    <item>
      <title>Re: Challenge Handler not called in WPF</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/challenge-handler-not-called-in-wpf/m-p/1198644#M11204</link>
      <description>&lt;P&gt;The desktop apps do have a API key set, because this was just going to be online.&amp;nbsp; The Xamarin is setup for offline.&lt;/P&gt;&lt;P&gt;Also, I am trying to do this using OAth not just user/password.&amp;nbsp; However, I have tried the approach you mention.&amp;nbsp; I will get the OAuth to popup, it seems I have a credential in there when looking at AuthenticationManager in debugger, but I get a token error&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 17:08:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/challenge-handler-not-called-in-wpf/m-p/1198644#M11204</guid>
      <dc:creator>JoeHershman</dc:creator>
      <dc:date>2022-08-02T17:08:42Z</dc:date>
    </item>
    <item>
      <title>Re: Challenge Handler not called in WPF</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/challenge-handler-not-called-in-wpf/m-p/1199288#M11209</link>
      <description>&lt;P&gt;Alright, thank your for this extra information!&amp;nbsp; I think I know what's going on.&lt;/P&gt;&lt;P&gt;Setting a global APIKey is meant to be an &lt;EM&gt;alternative&lt;/EM&gt; to making users log into the app.&amp;nbsp; It is &lt;A href="https://developers.arcgis.com/documentation/mapping-apis-and-services/security/#authentication-methods" target="_self"&gt;one of three ways to add an access token&lt;/A&gt; to app's network requests.&amp;nbsp; Mixing multiple token sources in one application can lead to problems.&amp;nbsp; What I think is happening in your case is -- having the API key set means that every request to arcgis.com already has an access token, which interferes with credential-challenge detection and can even prevent a TokenCredential from being used.&lt;/P&gt;&lt;P&gt;If your app will always require users to log in, then you probably don't need to use that API key.&amp;nbsp; See if removing the APIKey allows the ChallengeHandler and/or TokenCredential to work.&lt;/P&gt;&lt;P&gt;But if your app needs to have logging in optional -- e.g. by switching from API key to named-used authentication mid-flight -- that will be tricky.&amp;nbsp; That's not really a scenario we've tested so far, and I'd be curious to learn more about your use case.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 06:28:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/challenge-handler-not-called-in-wpf/m-p/1199288#M11209</guid>
      <dc:creator>MatveiStefarov</dc:creator>
      <dc:date>2022-08-04T06:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: Challenge Handler not called in WPF</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/challenge-handler-not-called-in-wpf/m-p/1199390#M11211</link>
      <description>&lt;P&gt;I'll give a try when I get the chance.&amp;nbsp; I will say, imo, that defeats the point of being able to use an API key for public layers.&amp;nbsp; An application that has a workflow of the user only needing a basemap without private operational layers is certainly realistic, and it would be nice if in these cases they didn't have to log on.&amp;nbsp; So the log-on would only pop up when they need to add an operational layer.&lt;/P&gt;&lt;P&gt;I'll let you know after I test&lt;/P&gt;&lt;P&gt;Thanks - Joe&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 14:20:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/challenge-handler-not-called-in-wpf/m-p/1199390#M11211</guid>
      <dc:creator>JoeHershman</dc:creator>
      <dc:date>2022-08-04T14:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: Challenge Handler not called in WPF</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/challenge-handler-not-called-in-wpf/m-p/1199604#M11212</link>
      <description>&lt;P&gt;A couple more ideas:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Instead of setting the global APIKey on ArcGISEnvironment, which affects access to everything on arcgis.com, you could try setting the APIKey properties on individual resources.&amp;nbsp; You could set a key on individual Basemaps, Layers, Tasks, or ServiceFeatureTables). Setting a key on one resource does not interfere with TokenCredentials for other resources.&lt;/LI&gt;&lt;LI&gt;Try resetting the global ApiKey property when there is a need to log into a protected resource.&amp;nbsp; I realize that this can be a tricky situation to detect when ChallengeHandler does not get called.&amp;nbsp; I'll investigate if we can detect the APIKey-TokenCredential clash in our networking code and at least provide more helpful error messages / make workarounds simpler.&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Thu, 04 Aug 2022 20:27:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/challenge-handler-not-called-in-wpf/m-p/1199604#M11212</guid>
      <dc:creator>MatveiStefarov</dc:creator>
      <dc:date>2022-08-04T20:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: Challenge Handler not called in WPF</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/challenge-handler-not-called-in-wpf/m-p/1199651#M11213</link>
      <description>&lt;P&gt;That did work.&amp;nbsp; Removed the setting of the APIKey at the initialization stage and then when trying to add the feature layer it works.&lt;/P&gt;&lt;P&gt;Right now have just ran a quick test but this should move me forward&lt;/P&gt;&lt;P&gt;Thanks - Joe&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 21:39:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/challenge-handler-not-called-in-wpf/m-p/1199651#M11213</guid>
      <dc:creator>JoeHershman</dc:creator>
      <dc:date>2022-08-04T21:39:40Z</dc:date>
    </item>
  </channel>
</rss>

