<?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 How to get ArcGIS Portal user content using Runtime .Net in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-get-arcgis-portal-user-content-using/m-p/1063455#M10138</link>
    <description>&lt;P&gt;I started a small exercise and had some features published via Arcmap as feature services, using the URL I was able to display those features on a base map on mobile devices, I wanted to kick this exercise up a notch, so I created a map on arcgis portal, and added those features as layers using the same account. Now I want to display the contents of that portal for the specific user, So again I had the user enter their credentials, so I can access their portal content, but I am getting an exception every time that I cannot figure out why&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;"Esri.ArcGISRuntime.Http.ArcGISWebException: You do not have permissions to access this resource or perform this operation. at Esri.ArcGISRuntime.Http.ArcGISHttpClientHandler+ArcGISClientHandlerInternal.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00e0a] in &amp;lt;46d786262d8c49d5b1ed57411302734a&amp;gt;:0 at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered (System.Threading.Tasks.Task`1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) "&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Also take a look at the code at the bottom, and let me know if I am missing something, the logic is I get the username and password, I create the Credential object, and set the ChallengeHandler. Then I use the URL of the portal to access the Portal object and set its Credential,also I use the PortalUser to access the user and get their content. what am I doing wrong to get the exception above ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a chunk of the code&lt;/P&gt;&lt;PRE&gt; &lt;SPAN class="hljs-function"&gt;&lt;SPAN class="hljs-keyword"&gt;public&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;async&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;void&lt;/SPAN&gt; &lt;SPAN class="hljs-title"&gt;LoginButtonClicked&lt;/SPAN&gt;()&lt;/SPAN&gt;{
           _tokenCredential = loginPageFrm.NetworkCred;  &lt;SPAN class="hljs-comment"&gt;// This contains the credential object&lt;/SPAN&gt;
           &lt;SPAN class="hljs-keyword"&gt;var&lt;/SPAN&gt; handler = &lt;SPAN class="hljs-keyword"&gt;new&lt;/SPAN&gt; ChallengeHandler(CreateCredentialAsync);
           AuthenticationManager.Current.ChallengeHandler = handler;                        
           &lt;SPAN class="hljs-keyword"&gt;var&lt;/SPAN&gt; arcgisPortal = &lt;SPAN class="hljs-keyword"&gt;await&lt;/SPAN&gt; ArcGISPortal.CreateAsync(uriPortal);
           arcgisPortal.Credential = _tokenCredential;
           &lt;SPAN class="hljs-keyword"&gt;var&lt;/SPAN&gt; loginType =&lt;SPAN class="hljs-keyword"&gt;await&lt;/SPAN&gt;  ArcGISPortal.GetLoginTypeForUriAsync(uriPortal);
           &lt;SPAN class="hljs-keyword"&gt;var&lt;/SPAN&gt; portUSer=&lt;SPAN class="hljs-keyword"&gt;await&lt;/SPAN&gt;  PortalUser.CreateAsync(arcgisPortal, loginPage.UserName);
           &lt;SPAN class="hljs-keyword"&gt;var&lt;/SPAN&gt; contents= &lt;SPAN class="hljs-keyword"&gt;await&lt;/SPAN&gt; portUSer.GetContentAsync(); &lt;SPAN class="hljs-comment"&gt;// where the exception occurs&lt;/SPAN&gt;

}&lt;/PRE&gt;&lt;PRE&gt; &lt;SPAN class="hljs-keyword"&gt;private&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;async&lt;/SPAN&gt; Task&amp;lt;Credential&amp;gt;CreateCredentialAsync(CredentialRequestInfo info){
           &lt;SPAN class="hljs-comment"&gt;// See if authentication is already in process&lt;/SPAN&gt;
          &lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt; (_loginTaskCompletionSource != &lt;SPAN class="hljs-literal"&gt;null&lt;/SPAN&gt;) { &lt;SPAN class="hljs-keyword"&gt;return&lt;/SPAN&gt; &lt;SPAN class="hljs-literal"&gt;null&lt;/SPAN&gt;; }
          _loginTaskCompletionSource = &lt;SPAN class="hljs-keyword"&gt;new&lt;/SPAN&gt; TaskCompletionSource&amp;lt;Credential&amp;gt;(info);
              &lt;SPAN class="hljs-keyword"&gt;try&lt;/SPAN&gt;
                  {
                   _loginTaskCompletionSource.TrySetResult(_tokenCredential);
                   &lt;SPAN class="hljs-keyword"&gt;return&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;await&lt;/SPAN&gt; _loginTaskCompletionSource.Task;
                  } 
                  catch (Exception ex)
                  {
                   _loginTaskCompletionSource = &lt;SPAN class="hljs-literal"&gt;null&lt;/SPAN&gt;;&lt;BR /&gt;                    Log.LogException(Ex,True);
                  }&lt;BR /&gt;                  &lt;SPAN class="hljs-keyword"&gt;return&lt;/SPAN&gt; &lt;SPAN class="hljs-literal"&gt;null&lt;/SPAN&gt;;
  }&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Jun 2021 22:03:12 GMT</pubDate>
    <dc:creator>ZaidOdeh</dc:creator>
    <dc:date>2021-06-03T22:03:12Z</dc:date>
    <item>
      <title>How to get ArcGIS Portal user content using Runtime .Net</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-get-arcgis-portal-user-content-using/m-p/1063455#M10138</link>
      <description>&lt;P&gt;I started a small exercise and had some features published via Arcmap as feature services, using the URL I was able to display those features on a base map on mobile devices, I wanted to kick this exercise up a notch, so I created a map on arcgis portal, and added those features as layers using the same account. Now I want to display the contents of that portal for the specific user, So again I had the user enter their credentials, so I can access their portal content, but I am getting an exception every time that I cannot figure out why&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;"Esri.ArcGISRuntime.Http.ArcGISWebException: You do not have permissions to access this resource or perform this operation. at Esri.ArcGISRuntime.Http.ArcGISHttpClientHandler+ArcGISClientHandlerInternal.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00e0a] in &amp;lt;46d786262d8c49d5b1ed57411302734a&amp;gt;:0 at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered (System.Threading.Tasks.Task`1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) "&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Also take a look at the code at the bottom, and let me know if I am missing something, the logic is I get the username and password, I create the Credential object, and set the ChallengeHandler. Then I use the URL of the portal to access the Portal object and set its Credential,also I use the PortalUser to access the user and get their content. what am I doing wrong to get the exception above ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a chunk of the code&lt;/P&gt;&lt;PRE&gt; &lt;SPAN class="hljs-function"&gt;&lt;SPAN class="hljs-keyword"&gt;public&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;async&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;void&lt;/SPAN&gt; &lt;SPAN class="hljs-title"&gt;LoginButtonClicked&lt;/SPAN&gt;()&lt;/SPAN&gt;{
           _tokenCredential = loginPageFrm.NetworkCred;  &lt;SPAN class="hljs-comment"&gt;// This contains the credential object&lt;/SPAN&gt;
           &lt;SPAN class="hljs-keyword"&gt;var&lt;/SPAN&gt; handler = &lt;SPAN class="hljs-keyword"&gt;new&lt;/SPAN&gt; ChallengeHandler(CreateCredentialAsync);
           AuthenticationManager.Current.ChallengeHandler = handler;                        
           &lt;SPAN class="hljs-keyword"&gt;var&lt;/SPAN&gt; arcgisPortal = &lt;SPAN class="hljs-keyword"&gt;await&lt;/SPAN&gt; ArcGISPortal.CreateAsync(uriPortal);
           arcgisPortal.Credential = _tokenCredential;
           &lt;SPAN class="hljs-keyword"&gt;var&lt;/SPAN&gt; loginType =&lt;SPAN class="hljs-keyword"&gt;await&lt;/SPAN&gt;  ArcGISPortal.GetLoginTypeForUriAsync(uriPortal);
           &lt;SPAN class="hljs-keyword"&gt;var&lt;/SPAN&gt; portUSer=&lt;SPAN class="hljs-keyword"&gt;await&lt;/SPAN&gt;  PortalUser.CreateAsync(arcgisPortal, loginPage.UserName);
           &lt;SPAN class="hljs-keyword"&gt;var&lt;/SPAN&gt; contents= &lt;SPAN class="hljs-keyword"&gt;await&lt;/SPAN&gt; portUSer.GetContentAsync(); &lt;SPAN class="hljs-comment"&gt;// where the exception occurs&lt;/SPAN&gt;

}&lt;/PRE&gt;&lt;PRE&gt; &lt;SPAN class="hljs-keyword"&gt;private&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;async&lt;/SPAN&gt; Task&amp;lt;Credential&amp;gt;CreateCredentialAsync(CredentialRequestInfo info){
           &lt;SPAN class="hljs-comment"&gt;// See if authentication is already in process&lt;/SPAN&gt;
          &lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt; (_loginTaskCompletionSource != &lt;SPAN class="hljs-literal"&gt;null&lt;/SPAN&gt;) { &lt;SPAN class="hljs-keyword"&gt;return&lt;/SPAN&gt; &lt;SPAN class="hljs-literal"&gt;null&lt;/SPAN&gt;; }
          _loginTaskCompletionSource = &lt;SPAN class="hljs-keyword"&gt;new&lt;/SPAN&gt; TaskCompletionSource&amp;lt;Credential&amp;gt;(info);
              &lt;SPAN class="hljs-keyword"&gt;try&lt;/SPAN&gt;
                  {
                   _loginTaskCompletionSource.TrySetResult(_tokenCredential);
                   &lt;SPAN class="hljs-keyword"&gt;return&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;await&lt;/SPAN&gt; _loginTaskCompletionSource.Task;
                  } 
                  catch (Exception ex)
                  {
                   _loginTaskCompletionSource = &lt;SPAN class="hljs-literal"&gt;null&lt;/SPAN&gt;;&lt;BR /&gt;                    Log.LogException(Ex,True);
                  }&lt;BR /&gt;                  &lt;SPAN class="hljs-keyword"&gt;return&lt;/SPAN&gt; &lt;SPAN class="hljs-literal"&gt;null&lt;/SPAN&gt;;
  }&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 22:03:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-get-arcgis-portal-user-content-using/m-p/1063455#M10138</guid>
      <dc:creator>ZaidOdeh</dc:creator>
      <dc:date>2021-06-03T22:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to get ArcGIS Portal user content using Runtime .Net</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-get-arcgis-portal-user-content-using/m-p/1064893#M10146</link>
      <description>&lt;P&gt;What's the value of&amp;nbsp;_tokenCredential when you set it?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 21:44:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-get-arcgis-portal-user-content-using/m-p/1064893#M10146</guid>
      <dc:creator>MichaelBranscomb</dc:creator>
      <dc:date>2021-06-03T21:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to get ArcGIS Portal user content using Runtime .Net</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-get-arcgis-portal-user-content-using/m-p/1064899#M10147</link>
      <description>&lt;P&gt;It contains the Credintial object. I set it in the first line in&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="hljs-function"&gt;&lt;SPAN class="hljs-title"&gt;LoginButtonClicked&lt;/SPAN&gt;()&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;The code uptop has a typo it's missing the underscore&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 22:02:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-get-arcgis-portal-user-content-using/m-p/1064899#M10147</guid>
      <dc:creator>ZaidOdeh</dc:creator>
      <dc:date>2021-06-03T22:02:25Z</dc:date>
    </item>
  </channel>
</rss>

