首页 > 解决方案 > SMS 2FA 如何在 .NET Core 3.0 中实现

问题描述

是否可以在 .net core 3 应用程序中使用 SMS 实现 2FA?

是的,我已经看过这个页面https://docs.microsoft.com/en-us/aspnet/core/security/authentication/2fa?view=aspnetcore-1.1&viewFallbackFrom=aspnetcore-3.0但接口 ISmsSender 不再存在.NET Core 3.0 Identity 也不是 .NET Core 2.0 。

所以我看不出这仍然可以实现吗?

为任何建议干杯

标签: c#asp.net-coreasp.net-identity.net-core-3.0

解决方案


您真的不需要库,大多数 SMS 网关都支持简单的 REST 调用。像 Microsoft.AspNet.WebApi.Client 这样的库应该就足够了 - POST 应该包含类似

curl -X "POST" "https://rest.nexmo.com/sms/json" \   -d "from=AcmeInc" \   -d "text=A text message sent using the Nexmo SMS

API" \ -d "to=$TO_NUMBER" \ -d "api_key=$NEXMO_API_KEY" \ -d "api_secret=$NEXMO_API_SECRET"

nexmo 也有一个 .Net 库https://developer.nexmo.com/messaging/sms/overview#sms-api-features


推荐阅读