コード例 #1
0
        private async Task <string> GetTokenAsync(string tokenCredentialsEncoded)
        {
            using (HttpClient httpClient = TwitterHelper.GetAuthorizationHttpClient(tokenCredentialsEncoded))
            {
                HttpResponseMessage response = await httpClient.PostAsync(
                    configuration["Twitter:OauthUrl"],
                    TwitterHelper.GetAuthorizationHttpContent()
                    );

                if (!response.IsSuccessStatusCode)
                {
                    return(null);
                }

                string respose = await response.Content.ReadAsStringAsync();

                JObject json     = JObject.Parse(respose);
                string  tokenKey = configuration["Twitter:TokenKey"];

                if (!json.ContainsKey(tokenKey))
                {
                    return(null);
                }

                return(json[tokenKey].ToString());
            }
        }