Пример #1
0
        private static void LogIn(AuthApi authApi)
        {
            authApi.AuthLogin(new Credentials(Username, Password, Tenant));
            Console.WriteLine("Logged In...");
            Configuration.Default = new Configuration(Default._18._200._001.EndpointHelper.CombineEndpointURL(SiteURL));

            //share cookie container between API clients because we use different client for authentication and interaction with endpoint
            Configuration.Default.ApiClient.RestClient.CookieContainer = authApi.Configuration.ApiClient.RestClient.CookieContainer;
        }
        private static Configuration LogIn(AuthApi authApi, string siteURL, string username, string password, string tenant = null, string branch = null, string locale = null)
        {
            var cookieContainer = new CookieContainer();

            authApi.Configuration.ApiClient.RestClient.CookieContainer = cookieContainer;

            authApi.AuthLogin(new Credentials(username, password, tenant, branch, locale));
            Console.WriteLine("Logged In...");
            var configuration = new Configuration(siteURL + "/entity/Default/18.200.001/");

            //share cookie container between API clients because we use different client for authentication and interaction with endpoint
            configuration.ApiClient.RestClient.CookieContainer = authApi.Configuration.ApiClient.RestClient.CookieContainer;
            return(configuration);
        }
        public void Initialize(string siteUrl, Credentials credentials)
        {
            try
            {
                _auth = new AuthApi(siteUrl);
                var cookieContainer = new CookieContainer();
                _auth.Configuration.ApiClient.RestClient.CookieContainer = cookieContainer;

                _config = new Configuration(siteUrl + DefaultEndpoint);
                _config.ApiClient.RestClient.CookieContainer = cookieContainer;

                _auth.AuthLogin(credentials);
            }
            catch (Exception e)
            {
                _logger.LogError(e, "There was an error when attempting to log on");
                Dispose();
                throw;
            }
        }