我正在開發一個使用C#的Web應用程序,該應用程序在註冊期間使用2因素身份驗證。我已經使用Nexmo的API嘗試了2FA。它運行良好。我所要做的就是打電話給他們的API並指定'to'號碼。這裏是代碼:Twilio Authy 2FA for OneCode C#實現
public ActionResult Start(string to)
{
var start = NumberVerify.Verify(new NumberVerify.VerifyRequest
{
number = to,
brand = "NexmoQS"
});
Session["requestID"] = start.request_id;
return View();
}
現在,我決定給Twilio一試。我遇到了Authy,這是過程。我發現他們的2FA API here。但我不明白我應該在哪裏輸入Nexmo中指定的'to'號碼。我是一名初學者,使用.NET(C#)代碼片段。這是代碼片段。請幫助我配置此代碼,因爲我可以在Nexmo中進行配置。
public static async Task VerifyPhoneAsync()
{
// Create client
var client = new HttpClient();
// Add authentication header
client.DefaultRequestHeaders.Add("X-Authy-API-Key", AuthyAPIKey);
// https://api.authy.com/protected/$AUTHY_API_FORMAT/phones/verification/check?phone_number=$USER_PHONE&country_code=$USER_COUNTRY&verification_code=$VERIFY_CODE
HttpResponseMessage response = await client.GetAsync("https://api.authy.com/protected/json/phones/verification/check?phone_number=5558675309&country_code=1&verification_code=3043");
// Get the response content.
HttpContent responseContent = response.Content;
// Get the stream of the content.
using (var reader = new StreamReader(await responseContent.ReadAsStreamAsync()))
{
// Write the output.
Console.WriteLine(await reader.ReadToEndAsync());
}
}
他們給捲曲實現他們的API here的,請幫我配置在C#。
curl "http://api.authy.com/protected/json/users/new?api_key=d57d919d11e6b221c9bf6f7c882028f9" \
-d user[email]="[email protected]" \
-d user[cellphone]="317-338-9302" \
-d user[country_code]="54"
當你運行這段代碼時會發生什麼?任何錯誤?你從API獲得什麼迴應? –
我無法運行此..它說無法找到'AuthyAPIKey' –
這是什麼說的呢? – Andy