Skip to content

Commit

Permalink
added functions
Browse files Browse the repository at this point in the history
[ + ] Added Client.register_google(string, string, string, string)
[ # ] Client.register() should no longer throw invalid request
  • Loading branch information
FabioGaming committed Apr 25, 2024
1 parent 9a3d58f commit 0a0bee2
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion Amino.NET/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,47 @@ public Task login_sid(string sessionId, bool fetchProfile = true, bool connectSo
return Task.CompletedTask;
}

/// <summary>
/// Allows you to register an Amino account using a google account
/// </summary>
/// <param name="nickname"></param>
/// <param name="googleToken"></param>
/// <param name="password"></param>
/// <param name="deviceId"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public Task register_google(string nickname, string googleToken, string password, string deviceId = null)
{
deviceId = deviceId == null ? helpers.generate_device_id() : deviceId;
RestClient client = new RestClient(helpers.BaseUrl);
RestRequest request = new RestRequest("/g/s/auth/login");
request.AddHeaders(headers);

Dictionary<string, object> data = new Dictionary<string, object>()
{
{ "secret", $"12 {googleToken}" },
{ "secret2", $"0 {password}" },
{ "deviceID", deviceId },
{ "clientType", 100 },
{ "nickname", nickname },
{ "latitude", 0 },
{ "longitude", 0 },
{ "address", null },
{ "clientCallbackURL", "narviiapp://relogin" },
{ "timestamp", helpers.GetTimestamp() * 1000 },
};

request.AddJsonBody(System.Text.Json.JsonSerializer.Serialize(data));
request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(System.Text.Json.JsonSerializer.Serialize(data)));

var response = client.ExecutePost(request);
if((int)response.StatusCode != 200) { throw new Exception(response.Content); }
if(debug) { Trace.WriteLine(response.Content); }
return Task.CompletedTask;
}




/// <summary>
/// Allows you to register an Amino account
Expand Down Expand Up @@ -427,7 +468,7 @@ public Task register(string _name, string _email, string _password, string _veri
RestClient client = new RestClient(helpers.BaseUrl);
RestRequest request = new RestRequest("/g/s/auth/register");
request.AddHeaders(headers);
request.AddJsonBody(data);
request.AddJsonBody(JsonConvert.SerializeObject(data));
request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data)));
var response = client.ExecutePost(request);
if ((int)response.StatusCode != 200) { throw new Exception(response.Content); }
Expand Down

0 comments on commit 0a0bee2

Please sign in to comment.