private static async Task <ShareFileClient> PasswordAuthentication(SampleUser user, string clientId, string clientSecret)
        {
            // Initialize ShareFileClient.
            var configuration = ShareFile.Api.Client.Configuration.Default();

            configuration.Logger = new DefaultLoggingProvider();

            var sfClient     = new ShareFileClient(ShareFileBaseAPIUrl, configuration);
            var oauthService = new OAuthService(sfClient, clientId, clientSecret);

            // Perform a password grant request.  Will give us an OAuthToken
            var oauthToken = await oauthService.PasswordGrantAsync(user.Username, user.Password, user.Subdomain, user.ControlPlane);

            // Add credentials and update sfClient with new BaseUri
            sfClient.AddOAuthCredentials(oauthToken);
            sfClient.BaseUri = oauthToken.GetUri();

            return(sfClient);
        }
        public static async Task Initialize()
        {
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls
                                                    | SecurityProtocolType.Tls11
                                                    | SecurityProtocolType.Tls12
                                                    | SecurityProtocolType.Ssl3;

            var user = new SampleUser
            {
                ControlPlane = ControlPlane,
                Username     = UserName,
                Password     = Password,
                Subdomain    = Subdomain
            };

            // Authenticate with username/password
            sfClient = await PasswordAuthentication(user, ClientID, ClientSecret);;

            // Create a Session
            var session = await sfClient.Sessions.Login().Expand("Principal").ExecuteAsync();
        }