예제 #1
0
        public async Task <JsonOAuth> refreshToken(string refreshtoken)
        {
            var httpClientRequest = new HttpClient();



            //    var jsonRequest = JsonConvert.SerializeObject(postData);
            // HttpContent content = new StringContent(jsonRequest, System.Text.Encoding.UTF8, "application/json");
            Url my_post = new Url("https://id.twitch.tv/oauth2/token", ClientId(), ClientSecret(), refreshtoken, "refresh_token");

            var result = await httpClientRequest.PostAsync(my_post.Url_feeder, null);

            try
            {
                var resultString = await result.Content.ReadAsStringAsync();

                var jsonResult = JsonConvert.DeserializeObject <JsonOAuth>(resultString);
                AuthenticatorHelper.UpdateJson(File.ReadAllText(CredentialsPath), resultString, CredentialsPath);
                // var jsonResult = JObject.Parse(resultString);
                System.Diagnostics.Debug.WriteLine(jsonResult);
                return(jsonResult);
            }

            catch
            {
                System.Diagnostics.Debug.WriteLine(result);
                return(null);
            }
        }
        public static void SetAuthenticatorsForGivenEmailAddress(EditContactViewModel viewModel, Person personBeingEdited)
        {
            if (!string.IsNullOrEmpty(viewModel.Email) && viewModel.Email != personBeingEdited.Email)
            {
                // Clear existing Authenticators (if any)
                personBeingEdited.PersonAllowedAuthenticators.Clear();
                Check.Ensure(!personBeingEdited.PersonAllowedAuthenticators.Any());

                // Set the allowed authenticators
                var authenticatorsToAllow       = AuthenticatorHelper.GetAuthenticatorsForEmailAddress(viewModel.Email);
                var personAllowedAuthenticators = authenticatorsToAllow.Select(x => new PersonAllowedAuthenticator(personBeingEdited, x));
                HttpRequestStorage.DatabaseEntities.PersonAllowedAuthenticators.AddRange(personAllowedAuthenticators);
            }
        }