Skip to content

Commit

Permalink
Merge pull request #267 from teilmeier/patch-1
Browse files Browse the repository at this point in the history
Update RemoteAuthenticationClient.cs
  • Loading branch information
michielpost authored Jan 11, 2022
2 parents fd4b8ed + 0df522b commit 91bf4cf
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Q42.HueApi/RemoteAuthenticationClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,17 @@ public RemoteAuthorizeResponse ProcessAuthorizeResponse(string responseData)
/// <returns></returns>
public async Task<AccessTokenResponse?> GetToken(string code)
{
var requestUri = new Uri($"https://api.meethue.com/v2/oauth2/token?code={code}&grant_type=authorization_code");
var requestUri = new Uri($"https://api.meethue.com/v2/oauth2/token");

var formParameters = new Dictionary<string, string> {
{"code", code},
{"grant_type", "authorization_code"}
};

var formContent = new FormUrlEncodedContent(formParameters);

//Do a token request
var responseTask = await _httpClient.PostAsync(requestUri, new StringContent(string.Empty)).ConfigureAwait(false);
var responseTask = await _httpClient.PostAsync(requestUri, formContent).ConfigureAwait(false);
var responseString = responseTask.Headers.WwwAuthenticate.ToString();
responseString = responseString.Replace("Digest ", string.Empty);
string nonce = GetNonce(responseString);
Expand All @@ -111,7 +118,7 @@ public RemoteAuthorizeResponse ProcessAuthorizeResponse(string responseData)
{
RequestUri = requestUri,
Method = HttpMethod.Post,

Content = formContent
};

//Build request
Expand Down

0 comments on commit 91bf4cf

Please sign in to comment.