// It is the same as the code generated by the Authenticator App
var totp = new TOTP()
{
secret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
};
// Create config
var config = new Configuration()
{
Username = "enterUser",
Password = "enterPassword ",
UserAgent = "TestClient/1.0 Sonic853"
};
Create ApiClient and AuthenticationApi
var client = new ApiClient();
var authApi = new AuthenticationApi(client, client, config);
try Verify2FA
try
{
Console.WriteLine($"Login...{config.Username}");
var currentUserResp = await authApi.GetCurrentUserWithHttpInfoAsync();
if (!resp.RawContent.Contains("totp"))
{
Console.WriteLine("Non-Totp verification is not supported");
return;
}
var code = totp.ComputeTotp();
Console.WriteLine($"Verify2FA...{code}");
await authApi.Verify2FAAsync(new(code));
Console.WriteLine($"Verify2FA...Done");
}
catch (ApiException ex)
{
Console.WriteLine($"Exception when calling API: {ex.Message}");
Console.WriteLine($"Status Code: {ex.ErrorCode}");
return;
}
Error
Exception when calling API: Error calling Verify2FA: {"error":{"message":"\"Missing Credentials\"","status_code":401}}
Step: