Skip to content

Commit 0a0bee2

Browse files
committed
added functions
[ + ] Added Client.register_google(string, string, string, string) [ # ] Client.register() should no longer throw invalid request
1 parent 9a3d58f commit 0a0bee2

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

Amino.NET/Client.cs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,47 @@ public Task login_sid(string sessionId, bool fetchProfile = true, bool connectSo
388388
return Task.CompletedTask;
389389
}
390390

391+
/// <summary>
392+
/// Allows you to register an Amino account using a google account
393+
/// </summary>
394+
/// <param name="nickname"></param>
395+
/// <param name="googleToken"></param>
396+
/// <param name="password"></param>
397+
/// <param name="deviceId"></param>
398+
/// <returns></returns>
399+
/// <exception cref="Exception"></exception>
400+
public Task register_google(string nickname, string googleToken, string password, string deviceId = null)
401+
{
402+
deviceId = deviceId == null ? helpers.generate_device_id() : deviceId;
403+
RestClient client = new RestClient(helpers.BaseUrl);
404+
RestRequest request = new RestRequest("/g/s/auth/login");
405+
request.AddHeaders(headers);
406+
407+
Dictionary<string, object> data = new Dictionary<string, object>()
408+
{
409+
{ "secret", $"12 {googleToken}" },
410+
{ "secret2", $"0 {password}" },
411+
{ "deviceID", deviceId },
412+
{ "clientType", 100 },
413+
{ "nickname", nickname },
414+
{ "latitude", 0 },
415+
{ "longitude", 0 },
416+
{ "address", null },
417+
{ "clientCallbackURL", "narviiapp://relogin" },
418+
{ "timestamp", helpers.GetTimestamp() * 1000 },
419+
};
420+
421+
request.AddJsonBody(System.Text.Json.JsonSerializer.Serialize(data));
422+
request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(System.Text.Json.JsonSerializer.Serialize(data)));
423+
424+
var response = client.ExecutePost(request);
425+
if((int)response.StatusCode != 200) { throw new Exception(response.Content); }
426+
if(debug) { Trace.WriteLine(response.Content); }
427+
return Task.CompletedTask;
428+
}
429+
430+
431+
391432

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

0 commit comments

Comments
 (0)