Esempio n. 1
0
        public void DeleteUser()
        {
            HttpClient Client           = new HttpClient();
            var        authenticateUser = new AuthenticateIdentityProviderUser();
            var        token            = authenticateUser.AuthAsync().GetAwaiter().GetResult();

            Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.access_token);

            string Uri      = "https://dmiqa2.calastonetest.com/login/oauth/users/" + this.userId;
            var    response = Client.DeleteAsync(Uri);
        }
Esempio n. 2
0
        public void DeleteUser()
        {
            HttpClient Client           = new HttpClient();
            var        authenticateUser = new AuthenticateIdentityProviderUser();
            var        token            = authenticateUser.AuthAsync().GetAwaiter().GetResult();

            Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.access_token);

            string Uri      = Config.Environment.IdentityProviderUsersEndpoint + this.userId;
            var    response = Client.DeleteAsync(Uri);
        }
Esempio n. 3
0
        public void DisableUser()
        {
            HttpClient Client           = new HttpClient();
            var        authenticateUser = new AuthenticateIdentityProviderUser();
            var        token            = authenticateUser.AuthAsync().GetAwaiter().GetResult();
            string     patchJson        = "[{'op': 'replace','path': '/disabled','value': true}]";

            var buffer      = System.Text.Encoding.UTF8.GetBytes(patchJson);
            var byteContent = new ByteArrayContent(buffer);

            byteContent.Headers.ContentType            = new MediaTypeHeaderValue("application/json");
            Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.access_token);
            Client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8");

            string Uri      = Config.Environment.IdentityProviderUsersEndpoint + this.userId;
            var    response = Client.PatchAsync(Uri, byteContent);
        }
Esempio n. 4
0
        public void DisableUser()
        {
            HttpClient Client           = new HttpClient();
            var        authenticateUser = new AuthenticateIdentityProviderUser();
            var        token            = authenticateUser.AuthAsync().GetAwaiter().GetResult();
            string     patchJson        = "[{'op': 'replace','path': '/disabled','value': true}]";

            //string aUser = JsonConvert.SerializeObject(newuser);
            var buffer      = System.Text.Encoding.UTF8.GetBytes(patchJson);
            var byteContent = new ByteArrayContent(buffer);

            byteContent.Headers.ContentType            = new MediaTypeHeaderValue("application/json");
            Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.access_token);
            Client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8");

            string Uri      = "https://dmiqa2.calastonetest.com/login/oauth/users/" + this.userId;
            var    response = Client.PatchAsync(Uri, byteContent);
        }
Esempio n. 5
0
        public async Task <IdentityProviderUserModel> CreateFromDmiUser(DMIUser dmiuser)
        {
            var authenticateUser = new AuthenticateIdentityProviderUser();
            var token            = authenticateUser.AuthAsync().GetAwaiter().GetResult();

            string aUser       = JsonConvert.SerializeObject(dmiuser);
            var    buffer      = System.Text.Encoding.UTF8.GetBytes(aUser);
            var    byteContent = new ByteArrayContent(buffer);

            byteContent.Headers.ContentType            = new MediaTypeHeaderValue("application/json");
            Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.access_token);
            Client.DefaultRequestHeaders.Add("cache-control", "no-cache");
            Client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8");

            var response = await Client.PostAsync(Config.Environment.IdentityProviderUsersEndpoint, byteContent);

            //read the body
            string responseBody = await response.Content.ReadAsStringAsync();

            string body = response.Content.ToString();

            return(user = parseUser(responseBody));
        }