示例#1
0
        /// <summary>
        /// Get the Authentication token for the Dashboard User.
        /// </summary>
        /// <param name="UserName">Dashboard UserName</param>
        /// <param name="Password">Password</param>
        /// <returns>Authentication token</returns>
        public async Task <string> GetDashboardAuthToken(string UserName, string Password)
        {
            string token = "";

            //prepare notify endpoint
            string path = string.Format("{0}Authentication/NotifEye", ConfigurationManager.AppSettings["NotifEyeIntegratedAPIEndpoint"]);

            var httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", AppUtility.Base64Encode(UserName + ":" + Password));

            //make api call
            HttpResponseMessage response = await httpClient.GetAsync(path);

            if (response.IsSuccessStatusCode)
            {
                IEnumerable <string> values;
                if (response.Headers.TryGetValues("authenticatedtoken", out values))
                {
                    token = values.First();
                }
            }
            return(token);
        }