ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Core Namespace / ArcGISPortal Class / SignIn Method
Example

In This Topic
    SignIn Method
    In This Topic
    Synchronous method to Sign on to this portal instance.
    Syntax
    Public Function SignIn() As SignInResult
    public SignInResult SignIn()

    Return Value

    A SignInResult containing the SignIn status
    Exceptions
    ExceptionDescription
    Thrown when a method is called on the wrong Pro thread
    Remarks
    If the sign on information is not cached, the OAuth dialog popup will be displayed. This method should be called from within a QueuedTask or System.Threading.Task unless the caller is within ArcGIS.Desktop.Framework.Contracts.ConfigurationManager.OnApplicationInitializing in which case the main thread should be used.
    Example
    ArcGISPortalManager: Get a portal and Sign In, Set it Active
    {
      //Find the portal to sign in with using its Uri...
      var uri = new Uri("http://myportal.esri.com/portal/", UriKind.Absolute);
      var aPortal = ArcGISPortalManager.Current.GetPortal(uri);
      if (!aPortal.IsSignedOn())
      {
        //Calling "SignIn" will trigger the OAuth popup if your credentials are
        //not cached (eg from a previous sign in in the session)
        if (portal.SignIn().success)
        {
          //Set this portal as my active portal
          ArcGISPortalManager.Current.SetActivePortal(portal);
        }
      }
    }
    Portal: Get the Current signed in User from the active portal
    {
      //Force login
      if (!portal.IsSignedOn())
      {
        portal.SignIn();
      }
      var user = portal.GetSignOnUsername();
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also