Beispiel #1
0
 public DMIUser(IdentityProviderUserModel identityProviderUserModel, string clientId)
 {
     this.username  = identityProviderUserModel.username;
     this.firstname = identityProviderUserModel.firstName;
     this.lastname  = identityProviderUserModel.lastName;
     this.email     = identityProviderUserModel.email;
     this.userId    = identityProviderUserModel.id;
     this.clientId  = clientId;
 }
Beispiel #2
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));
        }