public async Task <HttpResponseMessage> GetEmployeeDetailsFromAPI(string accessToken) { HttpClientObj.DefaultRequestHeaders.Accept.Clear(); HttpClientObj.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", accessToken); HttpClientObj.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.orcid+xml")); HttpResponseMessage response = await HttpClientObj.GetAsync("0000-0002-5807-5617" + "/record"); return(response); }
public async Task <HttpResponseMessage> GetEmployeeAccessTokenFromApi(string _code) { var nvc = new List <KeyValuePair <string, string> >(); nvc.Add(new KeyValuePair <string, string>("client_id", ConfigurationObj["ClientId"])); nvc.Add(new KeyValuePair <string, string>("client_secret", ConfigurationObj["ClientSecret"])); nvc.Add(new KeyValuePair <string, string>("grant_type", "authorization_code")); nvc.Add(new KeyValuePair <string, string>("code", _code)); nvc.Add(new KeyValuePair <string, string>("redirect_uri", ConfigurationObj["RedirectUri"])); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "/oauth/token"); request.Content = new FormUrlEncodedContent(nvc); HttpClientObj.DefaultRequestHeaders .Accept .Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await HttpClientObj.SendAsync(request, HttpCompletionOption.ResponseHeadersRead); return(response); }