Skip to content

Commit

Permalink
Update EOS.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
BattlefieldDuck committed Jan 22, 2024
1 parent 85bc784 commit 9d9bed4
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions OpenGSQ/Protocols/EOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,18 @@ public static async Task<string> GetAccessTokenAsync(string clientId, string cli
{
string url = $"{_apiUrl}/auth/v1/oauth/token";

var queryString = System.Web.HttpUtility.ParseQueryString(string.Empty);
queryString.Add("grant_type", grantType);
queryString.Add("external_auth_type", externalAuthType);
queryString.Add("external_auth_token", externalAuthToken);
queryString.Add("nonce", "opengsq");
queryString.Add("deployment_id", deploymentId);
queryString.Add("display_name", "User");
var values = new Dictionary<string, string>
{
{ "grant_type", grantType },
{ "external_auth_type", externalAuthType },
{ "external_auth_token", externalAuthToken },
{ "nonce", "opengsq" },
{ "deployment_id", deploymentId },
{ "display_name", "User" },
};

var content = new FormUrlEncodedContent(values);
var queryString = await content.ReadAsStringAsync();

string authInfo = $"{clientId}:{clientSecret}";
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
Expand All @@ -72,7 +77,7 @@ public static async Task<string> GetAccessTokenAsync(string clientId, string cli
}
})
{
HttpResponseMessage response = await client.PostAsync(url, new StringContent(queryString.ToString(), Encoding.UTF8, "application/x-www-form-urlencoded"));
HttpResponseMessage response = await client.PostAsync(url, new StringContent(queryString, Encoding.UTF8, "application/x-www-form-urlencoded"));
response.EnsureSuccessStatusCode();

var data = await response.Content.ReadFromJsonAsync<Dictionary<string, object>>();
Expand All @@ -96,8 +101,13 @@ public static async Task<string> GetExternalAuthTokenAsync(string clientId, stri
{
string url = $"{_apiUrl}/auth/v1/accounts/deviceid";

var queryString = System.Web.HttpUtility.ParseQueryString(string.Empty);
queryString.Add("deviceModel", "PC");
var values = new Dictionary<string, string>
{
{ "deviceModel", "PC" },
};

var content = new FormUrlEncodedContent(values);
var queryString = await content.ReadAsStringAsync();

string authInfo = $"{clientId}:{clientSecret}";
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
Expand All @@ -111,7 +121,7 @@ public static async Task<string> GetExternalAuthTokenAsync(string clientId, stri
}
})
{
HttpResponseMessage response = await client.PostAsync(url, new StringContent(queryString.ToString(), Encoding.UTF8, "application/x-www-form-urlencoded"));
HttpResponseMessage response = await client.PostAsync(url, new StringContent(queryString, Encoding.UTF8, "application/x-www-form-urlencoded"));
response.EnsureSuccessStatusCode();

var data = await response.Content.ReadFromJsonAsync<Dictionary<string, object>>();
Expand Down

0 comments on commit 9d9bed4

Please sign in to comment.