<?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: IdentityManager Question in ArcGIS Runtime SDK for WPF (Retired) Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/identitymanager-question/m-p/40920#M180</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;To programmatically generate a token, it seems that we must set the IdentityManager.Current.ChallengeMethod to the proper method which can give user/pw, and then call GenerateCredentialAsync from within the challenge method.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can also call GenerateCredentialAsync&amp;nbsp; out of the challenge method and then call AddCredential to register this credential with the IdentityManager. Once done, the IdentityManager will automatically use this credential to access to the specified arcgis resource (portal or server).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Example of code snippet:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;private Task InitIdentityManager()
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; var tcs = new TaskCompletionSource&amp;lt;bool&amp;gt;();
&amp;nbsp;&amp;nbsp;&amp;nbsp; IdentityManager.Current.TokenGenerationReferer = "arcgis.com";
&amp;nbsp;&amp;nbsp;&amp;nbsp; IdentityManager.Current.ChallengeMethodEx += SignInDialog.DoSignInEx; // activate the IM with the standard SignInDialog

&amp;nbsp;&amp;nbsp;&amp;nbsp; IdentityManager.Current.GenerateCredentialAsync("http://www.arcgis.com/sharing/rest", "username", "password", (crd, error) =&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (crd != null)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IdentityManager.Current.AddCredential(crd);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tcs.SetResult(true);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tcs.SetException(error ?? new Exception("Unknown error"));
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp; return tcs.Task;
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Instead of using GenerateCredentialAsync, you can also call GetCredentialAsync in order to challenge the user using the toolkit signInDialog.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;IdentityManager.Current.GetCredentialAsync("http://www.arcgis.com/sharing/rest", true, (crd, error) =&amp;gt;
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (crd != null)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IdentityManager.Current.AddCredential(crd);
});&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 21:35:12 GMT</pubDate>
    <dc:creator>DominiqueBroux</dc:creator>
    <dc:date>2021-12-10T21:35:12Z</dc:date>
    <item>
      <title>IdentityManager Question</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/identitymanager-question/m-p/40919#M179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To programmatically generate a token, it seems that we must set the IdentityManager.Current.ChallengeMethod to the proper method which can give user/pw, and then call GenerateCredentialAsync from within the challenge method. That method then also raises callback actions that were passed to it, and uses options that were passed to it. This can be seen in the SDK Sample: &lt;/SPAN&gt;&lt;STRONG&gt;Datasources-&amp;gt;Web Maps-&amp;gt;Load Secure WebMap&lt;/STRONG&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My question is, what functionality in the SDK will actually trigger the challenge method being called? It seems to be triggered when actually using a service that needs a token, via certain SDK objects (e.g. document.GetMapAsync). We want to programmatically generate this token when starting our application, and not wait for an unknown SDK object to trigger the call of the challenge method. Is this possible?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jun 2013 14:35:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/identitymanager-question/m-p/40919#M179</guid>
      <dc:creator>BrianRassier</dc:creator>
      <dc:date>2013-06-24T14:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: IdentityManager Question</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/identitymanager-question/m-p/40920#M180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;To programmatically generate a token, it seems that we must set the IdentityManager.Current.ChallengeMethod to the proper method which can give user/pw, and then call GenerateCredentialAsync from within the challenge method.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can also call GenerateCredentialAsync&amp;nbsp; out of the challenge method and then call AddCredential to register this credential with the IdentityManager. Once done, the IdentityManager will automatically use this credential to access to the specified arcgis resource (portal or server).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Example of code snippet:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;private Task InitIdentityManager()
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; var tcs = new TaskCompletionSource&amp;lt;bool&amp;gt;();
&amp;nbsp;&amp;nbsp;&amp;nbsp; IdentityManager.Current.TokenGenerationReferer = "arcgis.com";
&amp;nbsp;&amp;nbsp;&amp;nbsp; IdentityManager.Current.ChallengeMethodEx += SignInDialog.DoSignInEx; // activate the IM with the standard SignInDialog

&amp;nbsp;&amp;nbsp;&amp;nbsp; IdentityManager.Current.GenerateCredentialAsync("http://www.arcgis.com/sharing/rest", "username", "password", (crd, error) =&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (crd != null)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IdentityManager.Current.AddCredential(crd);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tcs.SetResult(true);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tcs.SetException(error ?? new Exception("Unknown error"));
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp; return tcs.Task;
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Instead of using GenerateCredentialAsync, you can also call GetCredentialAsync in order to challenge the user using the toolkit signInDialog.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;IdentityManager.Current.GetCredentialAsync("http://www.arcgis.com/sharing/rest", true, (crd, error) =&amp;gt;
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (crd != null)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IdentityManager.Current.AddCredential(crd);
});&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:35:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/identitymanager-question/m-p/40920#M180</guid>
      <dc:creator>DominiqueBroux</dc:creator>
      <dc:date>2021-12-10T21:35:12Z</dc:date>
    </item>
  </channel>
</rss>

