<?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 do I use ArcGISPortalManager? in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-i-use-arcgisportalmanager/m-p/765509#M418</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Gotcha,&lt;/P&gt;&lt;P&gt;Ok so:&lt;/P&gt;&lt;P&gt;1.&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;When the obsolete object will be purged from the next version, the code won't work anymore&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The obsolete class will still work at 1.4 (we have to keep it working or else it would break the API). It will be deprecated at the next major release which is a "2.0", not a 1.5, 1.6, 1.x, etc. which would be considered&amp;nbsp;minor releases&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;All documentation I have found are only for&amp;nbsp;the obsolete object (PortalManager) and nothing for&amp;nbsp;the new recommended object (ArcGisPortalManager,)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alpha snapshots do not have doc so, yes, you are definitely on the bleeding edge on a snapshot. I have copy/pasted a few things below. The samples will be switched to use&amp;nbsp;ArcGISPortalManager, ArcGISPortal with EsriHttpClient and not deprecated class(es) at 1.4. Documentation is released with the final version.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3.&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt; (This may get fixed in next releases, but) some of ArcGisPortalManager methods&amp;nbsp;do not work on any thread...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Definitely sounds like a bug in the alpha3. ArcGISPortalManager.Current and ArcGISPortal instances can be used on any thread at 1.4 final. Also, upgrade your snapshot to alpha4 if that is available.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&lt;/P&gt;&lt;H2 style="color: #333333; background-color: #ffffff; border-bottom: 1px solid #eeeeee; font-weight: 600; font-size: 1.5em; margin-top: 24px; margin-bottom: 16px; padding-bottom: 0.3em;" id="toc-hId-1793421800"&gt;ArcGISPortalManager: Get the Current Active Portal&lt;/H2&gt;&lt;DIV class="" style="color: #333333; background-color: #ffffff; margin-bottom: 16px;"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="" style="color: #a71d5d;"&gt;var&lt;/SPAN&gt; active_portal = ArcGISPortalManager.Current.GetActivePortal();
&lt;SPAN class="" style="color: #a71d5d;"&gt;string&lt;/SPAN&gt; uri = active_portal.PortalUri.ToString();&lt;/PRE&gt;&lt;/PRE&gt;&lt;H2 style="color: #333333; background-color: #ffffff; border-bottom: 1px solid #eeeeee; font-weight: 600; font-size: 1.5em; margin-top: 24px; margin-bottom: 16px; padding-bottom: 0.3em;" id="toc-hId--758735161"&gt;ArcGISPortal: Get the Current&amp;nbsp;Signed-on User&lt;/H2&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var user = active_portal.GetSignOnUsername();&lt;/PRE&gt;&lt;/DIV&gt;&lt;H2 style="color: #333333; background-color: #ffffff; border-bottom: 1px solid #eeeeee; font-weight: 600; font-size: 1.5em; margin-top: 24px; margin-bottom: 16px; padding-bottom: 0.3em;" id="toc-hId-984075174"&gt;ArcGISPortalManager: Get a list of all your Portals&lt;/H2&gt;&lt;DIV class="" style="color: #333333; background-color: #ffffff; margin-bottom: 16px;"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="" style="color: #a71d5d;"&gt;var&lt;/SPAN&gt; portals = ArcGISPortalManager.Current.GetPortals();
&lt;SPAN class="" style="color: #969896;"&gt;//Make a list of all the Uris
&lt;/SPAN&gt;&lt;SPAN class="" style="color: #a71d5d;"&gt;var&lt;/SPAN&gt; portalUris = portals.Select(p =&amp;gt; p.PortalUri.ToString()).ToList();&lt;/PRE&gt;&lt;/DIV&gt;&lt;H2 style="color: #333333; background-color: #ffffff; border-bottom: 1px solid #eeeeee; font-weight: 600; font-size: 1.5em; margin-top: 24px; margin-bottom: 16px; padding-bottom: 0.3em;" id="toc-hId--1568081787"&gt;ArcGISPortalManager: Add a portal to the list of portals&lt;/H2&gt;&lt;DIV class="" style="color: #333333; background-color: #ffffff; margin-bottom: 16px;"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="" style="color: #a71d5d;"&gt;var&lt;/SPAN&gt; portalUri = &lt;SPAN class="" style="color: #a71d5d;"&gt;new&lt;/SPAN&gt; Uri(&lt;SPAN class="" style="color: #183691;"&gt;&lt;SPAN class="" style="color: #183691;"&gt;"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fmyportal.esri.com%2Fportal%2F" target="_blank"&gt;http://myportal.esri.com/portal/&lt;/A&gt;&lt;SPAN class="" style="color: #183691;"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;, UriKind.Absolute); 
ArcGISPortalManager.Current.AddPortal(portalUri);&lt;/PRE&gt;&lt;/DIV&gt;&lt;H2 style="color: #333333; background-color: #ffffff; border-bottom: 1px solid #eeeeee; font-weight: 600; font-size: 1.5em; margin-top: 24px; margin-bottom: 16px; padding-bottom: 0.3em;" id="toc-hId-174728548"&gt;ArcGISPortalManager: Get a portal and Sign In, Set it Active&lt;/H2&gt;&lt;DIV class="" style="color: #333333; background-color: #ffffff; margin-bottom: 16px;"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="" style="color: #969896;"&gt;//Find the portal to sign in with using its Uri...
&lt;/SPAN&gt;&lt;SPAN class="" style="color: #a71d5d;"&gt;var&lt;/SPAN&gt; portal = ArcGISPortalManager.Current.GetPortal(&lt;SPAN class="" style="color: #a71d5d;"&gt;new&lt;/SPAN&gt; Uri(uri, UriKind.Absolute));
&lt;SPAN class="" style="color: #a71d5d;"&gt;if&lt;/SPAN&gt; (!portal.IsSignedOn()) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN class="" style="color: #969896;"&gt;&amp;nbsp; //Calling "SignIn" will trigger the OAuth popup if your credentials are&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN class="" style="color: #969896;"&gt;&amp;nbsp; //not cached (eg from a previous sign in in the session)&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN class="" style="color: #a71d5d;"&gt;&amp;nbsp; if&lt;/SPAN&gt; (portal.SignIn().success) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN class="" style="color: #969896;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Set this portal as my active portal&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ArcGISPortalManager.Current.SetActivePortal(portal);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; } 
}&lt;/PRE&gt;&lt;/DIV&gt;&lt;H2 style="color: #333333; background-color: #ffffff; border-bottom: 1px solid #eeeeee; font-weight: 600; font-size: 1.5em; margin-top: 24px; margin-bottom: 16px; padding-bottom: 0.3em;" id="toc-hId-1917538883"&gt;ArcGISPortalManager:Listen for the Portal Events&lt;/H2&gt;&lt;DIV class="" style="color: #333333; background-color: #ffffff; margin-bottom: 16px;"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;ArcGIS.Desktop.Core.Events.ActivePortalChangedEvent.Subscribe((args) =&amp;gt; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN class="" style="color: #a71d5d;"&gt;&amp;nbsp;&amp;nbsp; var&lt;/SPAN&gt; active_uri = args.ActivePortal?.PortalUri.ToString();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN class="" style="color: #969896;"&gt;&amp;nbsp;&amp;nbsp; //etc
&lt;/SPAN&gt;});&amp;nbsp; 
ArcGIS.Desktop.Core.Events.ArcGISPortalAddedEvent.Subscribe((args) =&amp;gt; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN class="" style="color: #a71d5d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/SPAN&gt; added_portal = args.Portal;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN class="" style="color: #969896;"&gt;&amp;nbsp;&amp;nbsp; //etc
&lt;/SPAN&gt;});&amp;nbsp; 
ArcGIS.Desktop.Core.Events.ArcGISPortalRemovedEvent.Subscribe((args) =&amp;gt; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN class="" style="color: #a71d5d;"&gt;&amp;nbsp;&amp;nbsp; var&lt;/SPAN&gt; old_uri = args.RemovedPortalUri;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN class="" style="color: #969896;"&gt;&amp;nbsp; //etc
&lt;/SPAN&gt;});&lt;/PRE&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 08:30:34 GMT</pubDate>
    <dc:creator>CharlesMacleod</dc:creator>
    <dc:date>2021-12-12T08:30:34Z</dc:date>
    <item>
      <title>How do I use ArcGISPortalManager?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-i-use-arcgisportalmanager/m-p/765506#M415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm working with ArcGis Pro 1.4.0-alpha.3&lt;/P&gt;&lt;P&gt;My goal is to get a GeoDatabase or a Zip file produced in my extension and move it in MyContent on the portal.&lt;/P&gt;&lt;P&gt;I set up the portal in Project/Portals:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="277293" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/277293_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;And I want to use that setting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, trying to use PortalManager (documented in&amp;nbsp;&lt;A class="link-titled" href="http://pro.arcgis.com/en/pro-app/sdk/api-reference/#topic9169.html" title="http://pro.arcgis.com/en/pro-app/sdk/api-reference/#topic9169.html" rel="nofollow noopener noreferrer" target="_blank"&gt;ArcGIS Pro 1.3 API Reference Guide&lt;/A&gt;&amp;nbsp;- How do I get the help for 1.4?) I'm told thet this object is obsolete and redirected to use ArcGISPortalManager, which shows up in the code as part of ArcGis.Desktop.Core, but has peculiarities: most of its methods (which look fine and I want to use,) do not work on the current thread, and do not work on the&amp;nbsp;QueuedTask thread!&lt;/P&gt;&lt;P&gt;Starting with GetActivePortal, I try to do this (on a constructor of a button):&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;QueuedTask.Run(() =&amp;gt;
{&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;var a = ArcGISPortalManager.Current.GetActivePortal();
&amp;nbsp;&amp;nbsp;&amp;nbsp;IsChecked = a.IsSignedOn();
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It does not work either with or without the QueryTask, neither in the constructor, nor in InClick event! (I have even tried in other parts of the extension, as in the initialization of the Module!)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I've found some work-around to obtain the active portal and open it in the browser:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;protected override void OnClick()
 {
#pragma warning disable 618
 &amp;nbsp;&amp;nbsp;&amp;nbsp;var url = new UriBuilder(PortalManager.GetActivePortal())
 &amp;nbsp;&amp;nbsp;&amp;nbsp;{
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Path = "home/content.html"
 &amp;nbsp;&amp;nbsp;&amp;nbsp;};
#pragma warning restore 618
&amp;nbsp;&amp;nbsp;&amp;nbsp;Process.Start(url.Uri.AbsoluteUri);
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This code mixes the obsolete PortalManager with the new one (as in):&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;#pragma warning disable 618
 m_portal = ArcGISPortalManager.Current.GetPortal(PortalManager.GetActivePortal());
#pragma warning restore 618‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And does not let me use the wonderful methods of ArcGISPortal objects (m-portal) for the treading issues already mentioned!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:30:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-i-use-arcgisportalmanager/m-p/765506#M415</guid>
      <dc:creator>HoriaTudosie</dc:creator>
      <dc:date>2021-12-12T08:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use ArcGISPortalManager?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-i-use-arcgisportalmanager/m-p/765507#M416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your code, as such, looks ok. The alpha 3 snapshot likely has bugs. You should have access to the alpha 4 snapshot otherwise please re-try on 1.4 final (available dec, jan).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Dec 2016 19:35:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-i-use-arcgisportalmanager/m-p/765507#M416</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2016-12-12T19:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use ArcGISPortalManager?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-i-use-arcgisportalmanager/m-p/765508#M417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Charles,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sure the&amp;nbsp;Alpha may have bugs and I'll wait the new release to continue.&lt;/P&gt;&lt;P&gt;However, my code does not look OK since it uses a pragma to enable an obsolete object.&lt;/P&gt;&lt;P&gt;The issues I have are:&lt;/P&gt;&lt;P&gt;1. When the obsolete object will be purged from the next version, the code won't work anymore,&lt;/P&gt;&lt;P&gt;2. All documentation I have found are only for&amp;nbsp;the obsolete object (PortalManager) and nothing for&amp;nbsp;the new recommended object (ArcGisPortalManager,)&lt;/P&gt;&lt;P&gt;3. (This may get fixed in next releases, but) some of ArcGisPortalManager methods&amp;nbsp;do not work on any thread...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tx,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Dec 2016 20:35:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-i-use-arcgisportalmanager/m-p/765508#M417</guid>
      <dc:creator>HoriaTudosie</dc:creator>
      <dc:date>2016-12-12T20:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use ArcGISPortalManager?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-i-use-arcgisportalmanager/m-p/765509#M418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Gotcha,&lt;/P&gt;&lt;P&gt;Ok so:&lt;/P&gt;&lt;P&gt;1.&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;When the obsolete object will be purged from the next version, the code won't work anymore&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The obsolete class will still work at 1.4 (we have to keep it working or else it would break the API). It will be deprecated at the next major release which is a "2.0", not a 1.5, 1.6, 1.x, etc. which would be considered&amp;nbsp;minor releases&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;All documentation I have found are only for&amp;nbsp;the obsolete object (PortalManager) and nothing for&amp;nbsp;the new recommended object (ArcGisPortalManager,)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alpha snapshots do not have doc so, yes, you are definitely on the bleeding edge on a snapshot. I have copy/pasted a few things below. The samples will be switched to use&amp;nbsp;ArcGISPortalManager, ArcGISPortal with EsriHttpClient and not deprecated class(es) at 1.4. Documentation is released with the final version.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3.&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt; (This may get fixed in next releases, but) some of ArcGisPortalManager methods&amp;nbsp;do not work on any thread...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Definitely sounds like a bug in the alpha3. ArcGISPortalManager.Current and ArcGISPortal instances can be used on any thread at 1.4 final. Also, upgrade your snapshot to alpha4 if that is available.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&lt;/P&gt;&lt;H2 style="color: #333333; background-color: #ffffff; border-bottom: 1px solid #eeeeee; font-weight: 600; font-size: 1.5em; margin-top: 24px; margin-bottom: 16px; padding-bottom: 0.3em;" id="toc-hId-1793421800"&gt;ArcGISPortalManager: Get the Current Active Portal&lt;/H2&gt;&lt;DIV class="" style="color: #333333; background-color: #ffffff; margin-bottom: 16px;"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="" style="color: #a71d5d;"&gt;var&lt;/SPAN&gt; active_portal = ArcGISPortalManager.Current.GetActivePortal();
&lt;SPAN class="" style="color: #a71d5d;"&gt;string&lt;/SPAN&gt; uri = active_portal.PortalUri.ToString();&lt;/PRE&gt;&lt;/PRE&gt;&lt;H2 style="color: #333333; background-color: #ffffff; border-bottom: 1px solid #eeeeee; font-weight: 600; font-size: 1.5em; margin-top: 24px; margin-bottom: 16px; padding-bottom: 0.3em;" id="toc-hId--758735161"&gt;ArcGISPortal: Get the Current&amp;nbsp;Signed-on User&lt;/H2&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var user = active_portal.GetSignOnUsername();&lt;/PRE&gt;&lt;/DIV&gt;&lt;H2 style="color: #333333; background-color: #ffffff; border-bottom: 1px solid #eeeeee; font-weight: 600; font-size: 1.5em; margin-top: 24px; margin-bottom: 16px; padding-bottom: 0.3em;" id="toc-hId-984075174"&gt;ArcGISPortalManager: Get a list of all your Portals&lt;/H2&gt;&lt;DIV class="" style="color: #333333; background-color: #ffffff; margin-bottom: 16px;"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="" style="color: #a71d5d;"&gt;var&lt;/SPAN&gt; portals = ArcGISPortalManager.Current.GetPortals();
&lt;SPAN class="" style="color: #969896;"&gt;//Make a list of all the Uris
&lt;/SPAN&gt;&lt;SPAN class="" style="color: #a71d5d;"&gt;var&lt;/SPAN&gt; portalUris = portals.Select(p =&amp;gt; p.PortalUri.ToString()).ToList();&lt;/PRE&gt;&lt;/DIV&gt;&lt;H2 style="color: #333333; background-color: #ffffff; border-bottom: 1px solid #eeeeee; font-weight: 600; font-size: 1.5em; margin-top: 24px; margin-bottom: 16px; padding-bottom: 0.3em;" id="toc-hId--1568081787"&gt;ArcGISPortalManager: Add a portal to the list of portals&lt;/H2&gt;&lt;DIV class="" style="color: #333333; background-color: #ffffff; margin-bottom: 16px;"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="" style="color: #a71d5d;"&gt;var&lt;/SPAN&gt; portalUri = &lt;SPAN class="" style="color: #a71d5d;"&gt;new&lt;/SPAN&gt; Uri(&lt;SPAN class="" style="color: #183691;"&gt;&lt;SPAN class="" style="color: #183691;"&gt;"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fmyportal.esri.com%2Fportal%2F" target="_blank"&gt;http://myportal.esri.com/portal/&lt;/A&gt;&lt;SPAN class="" style="color: #183691;"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;, UriKind.Absolute); 
ArcGISPortalManager.Current.AddPortal(portalUri);&lt;/PRE&gt;&lt;/DIV&gt;&lt;H2 style="color: #333333; background-color: #ffffff; border-bottom: 1px solid #eeeeee; font-weight: 600; font-size: 1.5em; margin-top: 24px; margin-bottom: 16px; padding-bottom: 0.3em;" id="toc-hId-174728548"&gt;ArcGISPortalManager: Get a portal and Sign In, Set it Active&lt;/H2&gt;&lt;DIV class="" style="color: #333333; background-color: #ffffff; margin-bottom: 16px;"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="" style="color: #969896;"&gt;//Find the portal to sign in with using its Uri...
&lt;/SPAN&gt;&lt;SPAN class="" style="color: #a71d5d;"&gt;var&lt;/SPAN&gt; portal = ArcGISPortalManager.Current.GetPortal(&lt;SPAN class="" style="color: #a71d5d;"&gt;new&lt;/SPAN&gt; Uri(uri, UriKind.Absolute));
&lt;SPAN class="" style="color: #a71d5d;"&gt;if&lt;/SPAN&gt; (!portal.IsSignedOn()) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN class="" style="color: #969896;"&gt;&amp;nbsp; //Calling "SignIn" will trigger the OAuth popup if your credentials are&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN class="" style="color: #969896;"&gt;&amp;nbsp; //not cached (eg from a previous sign in in the session)&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN class="" style="color: #a71d5d;"&gt;&amp;nbsp; if&lt;/SPAN&gt; (portal.SignIn().success) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN class="" style="color: #969896;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Set this portal as my active portal&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ArcGISPortalManager.Current.SetActivePortal(portal);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; } 
}&lt;/PRE&gt;&lt;/DIV&gt;&lt;H2 style="color: #333333; background-color: #ffffff; border-bottom: 1px solid #eeeeee; font-weight: 600; font-size: 1.5em; margin-top: 24px; margin-bottom: 16px; padding-bottom: 0.3em;" id="toc-hId-1917538883"&gt;ArcGISPortalManager:Listen for the Portal Events&lt;/H2&gt;&lt;DIV class="" style="color: #333333; background-color: #ffffff; margin-bottom: 16px;"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;ArcGIS.Desktop.Core.Events.ActivePortalChangedEvent.Subscribe((args) =&amp;gt; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN class="" style="color: #a71d5d;"&gt;&amp;nbsp;&amp;nbsp; var&lt;/SPAN&gt; active_uri = args.ActivePortal?.PortalUri.ToString();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN class="" style="color: #969896;"&gt;&amp;nbsp;&amp;nbsp; //etc
&lt;/SPAN&gt;});&amp;nbsp; 
ArcGIS.Desktop.Core.Events.ArcGISPortalAddedEvent.Subscribe((args) =&amp;gt; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN class="" style="color: #a71d5d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/SPAN&gt; added_portal = args.Portal;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN class="" style="color: #969896;"&gt;&amp;nbsp;&amp;nbsp; //etc
&lt;/SPAN&gt;});&amp;nbsp; 
ArcGIS.Desktop.Core.Events.ArcGISPortalRemovedEvent.Subscribe((args) =&amp;gt; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN class="" style="color: #a71d5d;"&gt;&amp;nbsp;&amp;nbsp; var&lt;/SPAN&gt; old_uri = args.RemovedPortalUri;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;SPAN class="" style="color: #969896;"&gt;&amp;nbsp; //etc
&lt;/SPAN&gt;});&lt;/PRE&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:30:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-i-use-arcgisportalmanager/m-p/765509#M418</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2021-12-12T08:30:34Z</dc:date>
    </item>
  </channel>
</rss>

