Exemple #1
0
        /// <summary>
        /// 環境変数以外から取得した値を利用して、アクセストークンを取得する。
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static async Task <AccessTokenResponce> GetAccessTokenAsync(AccessTokenRequest request)
        {
            var url = Settings.URL.AccessTokenUrl;
            AccessTokenResponce responce =
                await HttpClientManager.ExecutePostAsync <AccessTokenRequest, AccessTokenResponce>(url, request);

            //set the bearer value for the next API call.
            CotohaApiManager.BearerValue =
                responce.StatusCode == HttpStatusCode.Created ? responce.AccessToken : string.Empty;

            return(responce);
        }
        public void TestMethod1()
        {
            var contents = new SampleObject()
            {
                password = "******",
                usernameOrEmailAddress = "dummy",
                tenancyName            = "dummy"
            };
            var result = HttpClientManager.ExecutePostAsync <SampleObject>("https://academy2016.uipath.com/api/account/authenticate", contents).Result;

            Assert.AreEqual("An error has occured", result.ResponceContent);
        }
Exemple #3
0
        private bool ExecuteAuthenticate(OrchestartorModel model)
        {
            var contents = new OrcAuthenticationModel()
            {
                password               = model.Password,
                tenancyName            = model.TenantName,
                usernameOrEmailAddress = model.UserId
            };
            string url  = $"https://{model.HostName}/api/account/authenticate";
            var    task = HttpClientManager.ExecutePostAsync <OrcAuthenticationModel>(url, contents);

            ConsoleUtil.PrintLoadingString <OrcAuthenticationModel>(task);

            HttpClientManager.BearerValue = task.Result.result;
            return(task.Result.success);
        }
Exemple #4
0
        /// <summary>
        /// 環境変数から値を設定して、アクセストークンを取得する。
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static async Task <AccessTokenResponce> GetAccessTokenAsync()
        {
            var url     = Settings.URL.AccessTokenUrl;
            var request = new AccessTokenRequest()
            {
                GrantType    = "client_credentials",
                ClientId     = CotohaAPI.Settings.AccountInfo.DeveloperClientId,
                ClientSecret = CotohaAPI.Settings.AccountInfo.DeveloperClientSecret
            };


            AccessTokenResponce responce =
                await HttpClientManager.ExecutePostAsync <AccessTokenRequest, AccessTokenResponce>(url, request);

            //set the bearer value for the next API call.
            CotohaApiManager.BearerValue =
                (responce.StatusCode == HttpStatusCode.Created) ? responce.AccessToken : string.Empty;
            return(responce);
        }