LoginRadius ASP.NET 客户注册包装器提供对 LoginRadius 身份管理平台 API 的访问。
LoginRadius 是一个身份管理平台,可在保护数据的同时简化用户注册。 LoginRadius 平台简化并保护您的用户注册流程,通过结合 30 个主要社交平台的社交登录提高转化率,并提供传统用户注册的完整解决方案。您可以从社交登录或传统用户注册中收集大量的用户个人资料数据。
LoginRadius 将所有内容集中在一处,使其易于管理和访问。轻松将 LoginRadius 与您的所有第三方应用程序(例如 MailChimp、Google Analytics、Livefyre 等)集成,从而轻松利用您正在捕获的数据。
LoginRadius 帮助企业提高网络/移动平台上的用户参与度、管理在线身份、利用社交媒体进行营销、捕获准确的消费者数据,并获得对其客户群的独特社交洞察。
请访问此处了解更多信息。
本文档假定您已完成客户端实现来设置 LoginRadius 用户注册界面,该界面将服务于初始注册和登录过程。有关详细信息,请参阅入门指南。
**注意:**LoginRadius 使用行业标准 TLS 1.2 协议,旨在帮助保护通过互联网通信的信息的隐私。为了使用 LoginRadius .Net SDK,请在项目的Global.asax
文件中实例化 Web 服务之前添加以下代码。
ServicePointManager . SecurityProtocol = SecurityProtocolType . Tls | SecurityProtocolType . Tls11 | SecurityProtocolType . Tls12 ;
从 Github 下载用户注册 .Net SDK
将 LoginRadiusSDK.V2.dll 和 LoginRadiusSDK.V2.pdb 文件复制到 ASP.NET 项目的 References 目录中。
或者
PM> Install-Package LoginRadiusSDK.NET
或者
使用 Visual Studio 2019 打开解决方案。
构建项目并记下 .nupkg 文件所在的位置。
访问 NuGet 包管理器设置并导入 .nupkg 文件所在的目录。
访问“管理解决方案的 NuGet 包...”工具,将源更改为新创建的源,然后选择并安装 LoginRadius SDK
接下来,在您的项目中包含以下命名空间:
using LoginRadiusSDK . V2 . Api ;
using LoginRadiusSDK . V2 . Models ;
在使用 SDK 之前,您必须使用以下代码初始化 SDK:API Key 和 LoginRadius 站点的密钥。此信息可以在您的 LoginRadius 帐户中找到,如下所述
LoginRadiusSdkGlobalConfig . ApiKey = "__API_KEY__" ;
LoginRadiusSdkGlobalConfig . ApiSecret = "__API_SECRET__" ;
LoginRadiusSdkGlobalConfig . AppName = "__LoginRadius_APP_NAME__" ;
LoginRadiusSdkGlobalConfig . ApiRequestSigning = "false" ;
LoginRadiusSdkGlobalConfig . ConnectionTimeout = 30000 ; // Connection Timeout (milliseconds)
LoginRadiusSdkGlobalConfig . ProxyAddress = "__HTTP_PROXY_ADDRESS__" ; // Absolute Proxy URI
LoginRadiusSdkGlobalConfig . ProxyCredentials = "__HTTP_PROXY_CREDENTIALS__" ; // Proxy Credentials in the format 'USERNAME:PASSWORD'
LoginRadiusSdkGlobalConfig . RequestRetries = 3 ;
LoginRadiusSdkGlobalConfig . ApiRegion = "_region_" ;
LoginRadiusSdkGlobalConfig . DomainName = "https://api.loginradius.com/" ;
或者
对于 ASP.NET。在web.config
中:
< configSections >
< section name = " loginradius " type = " LoginRadiusSDK.V2.SDKConfigHandler, LoginRadiusSDK.V2 " />
</ configSections >
<!-- LoginRadius SDK settings -->
< loginradius >
< settings >
< add name = " apiKey " value = " __API_KEY__ " />
< add name = " apiSecret " value = " __API_SECRET__ " />
< add name = " appName " value = " __LoginRadius_APP_NAME__ " />
< add name = " ApiRequestSigning " value = " false " />
< add name = " proxyAddress " value = " __HTTP_PROXY_ADDRESS__ " /> <!-- Absolute Proxy URI -->
< add name = " proxyCredentials " value = " __HTTP_PROXY_CREDENTIALS__ " /> <!-- Proxy Credentials in the format 'USERNAME:PASSWORD' -->
< add name = " connectionTimeout " value = " __HTTP_CONNECTION_TIMEOUT__ " /> <!-- Connection Timeout (milliseconds) -->
< add name = " requestRetries " value = " __HTTP_CONNECTION_RETRY__ " />
< add name = " apiRegion " value = " _region_ " />
< add name = " domainName " value = " https://api.loginradius.com/ " />
</ settings >
</ loginradius >
或者
对于 .NET Core,在appsettings.json
中:
JSON
"loginradius" : {
"apiKey" : " __API_KEY__ " ,
"apiSecret" : " __API_SECRET__ " ,
"appName" : " __LoginRadius_APP_NAME__ " ,
"ApiRequestSigning" : " false " ,
"proxyAddress" : " __HTTP_PROXY_ADDRESS__ " ,
"proxyCredentials" : " __HTTP_PROXY_CREDENTIAL__ " ,
"connectionTimeout" : " __HTTP_CONNECTION_TIMEOUT__ " ,
"requestRetries" : " __HTTP_CONNECTION_RETRY__ " ,
"apiRegion" : " _region_ " ,
"domainName" : " https://api.loginradius.com/ "
}
初始化 SDK 时,可以选择指定自定义域。示例:在 appsettings.json 中,添加以下语句 -
"domainName" : " https://api.loginradius.com/ "
初始化 SDK 时,您可以选择指定启用此功能。启用此功能意味着客户不需要在 API 请求中传递 API 密钥。相反,他们可以传递动态生成的哈希值。此功能还将确保当有人调用我们的 API 时消息在传输过程中不会被篡改。示例:在 appsettings.json 中,添加以下语句 -
"ApiRequestSigning" : " false "
X-Origin-IP LoginRadius 允许您在标头中添加 X-Origin-IP,它确定客户端请求的 IP 地址,这对于克服分析依赖于标头数据的分析差异也很有用。
"originIp" : " <Client-Ip-Address> "
本节中的 API 列表:
PUT :通过令牌更新配置文件
PUT :通过访问令牌验证解锁帐户
PUT :通过 OTP 验证电子邮件
PUT :通过安全答案和电子邮件验证重置密码
PUT :通过安全应答和电话验证重置密码
PUT :通过安全答案和用户名验证重置密码
PUT :通过重置令牌验证重置密码
PUT :通过 OTP 验证重置密码
PUT :通过 OTP 和用户名验证重置密码
PUT : 验证更改密码
POST:验证链接社交身份
POST:通过 Ping 验证链接社交身份
PUT :验证设置或更改用户名
PUT : Auth 重新发送电子邮件验证
POST : 验证添加电子邮件
POST :通过电子邮件验证登录
POST :通过用户名验证登录
POST : 身份验证 忘记密码
POST :通过电子邮件验证用户注册
POST :通过验证码验证用户注册
GET :通过电子邮件获取安全问题
GET :按用户名获取安全问题
GET :通过电话获取安全问题
GET :通过访问令牌获取安全问题
GET :身份验证验证访问令牌
GET :访问令牌无效
GET :访问令牌信息
GET :Auth 通过令牌读取所有配置文件
GET :验证发送欢迎电子邮件
GET : 授权删除帐户
GET :通过 Ping 获取配置文件
GET :验证检查电子邮件可用性
GET : 验证邮箱
GET:验证社交身份
GET :身份验证检查用户名可用性
GET:身份验证隐私政策接受
GET:通过访问令牌验证隐私政策历史记录
GET :Auth 发送验证电子邮件以链接社交资料
删除:通过电子邮件确认验证删除帐户
删除:验证删除电子邮件
删除:验证取消链接社交身份
该API用于通过传递access_token来更新用户的个人资料。更多信息
var accessToken = "accessToken" ; //Required
UserProfileUpdateModel userProfileUpdateModel = new UserProfileUpdateModel {
FirstName = "<FirstName>" ,
LastName = "<LastName>"
} ; //Required
var emailTemplate = "emailTemplate" ; //Optional
string fields = null ; //Optional
; //Optional
var smsTemplate = "smsTemplate" ; //Optional
var verificationUrl = "verificationUrl" ; //Optional
var isVoiceOtp = false ; //Optional
var options = "options" ; //Optional
var apiResponse = new AuthenticationApi ( ) . UpdateProfileByAccessToken ( accessToken , userProfileUpdateModel , emailTemplate , fields , smsTemplate , verificationUrl , isVoiceOtp , options ) . Result ;
此 API 用于允许拥有有效 access_token 的客户解锁其帐户,前提是他们成功通过了提示的机器人防护挑战。阻止或暂停块类型不适用于此 API。有关其他详细信息,请参阅我们的身份验证安全配置文档。您只需传递与提示的挑战相对应的发布参数。更多信息
var accessToken = "accessToken" ; //Required
UnlockProfileModel unlockProfileModel = new UnlockProfileModel {
G_recaptcha_response = "<G-recaptcha-response>"
} ; //Required
var apiResponse = new AuthenticationApi ( ) . UnlockAccountByToken ( accessToken , unlockProfileModel ) . Result ;
该API用于在启用OTP电子邮件验证流程时验证用户的电子邮件,请注意,您必须联系LoginRadius才能启用此功能。更多信息
EmailVerificationByOtpModel emailVerificationByOtpModel = new EmailVerificationByOtpModel {
Email = "<Email>" ,
Otp = "<Otp>"
} ; //Required
string fields = null ; //Optional
var url = "url" ; //Optional
var welcomeEmailTemplate = "welcomeEmailTemplate" ; //Optional
var apiResponse = new AuthenticationApi ( ) . VerifyEmailByOTP ( emailVerificationByOtpModel , fields , url , welcomeEmailTemplate ) . Result ;
该接口用于通过安全问题重置指定账户的密码 更多信息
ResetPasswordBySecurityAnswerAndEmailModel resetPasswordBySecurityAnswerAndEmailModel = new ResetPasswordBySecurityAnswerAndEmailModel {
Email = "<Email>" ,
Password = "<Password>" ,
SecurityAnswer = new Dictionary < String , String > {
[ "QuestionID" ] = "Answer"
}
} ; //Required
var apiResponse = new AuthenticationApi ( ) . ResetPasswordBySecurityAnswerAndEmail ( resetPasswordBySecurityAnswerAndEmailModel ) . Result ;
该接口用于通过安全问题重置指定账户的密码 更多信息
ResetPasswordBySecurityAnswerAndPhoneModel resetPasswordBySecurityAnswerAndPhoneModel = new ResetPasswordBySecurityAnswerAndPhoneModel {
Password = "<Password>" ,
Phone = "<Phone>" ,
SecurityAnswer = new Dictionary < String , String > {
[ "QuestionID" ] = "Answer"
}
} ; //Required
var apiResponse = new AuthenticationApi ( ) . ResetPasswordBySecurityAnswerAndPhone ( resetPasswordBySecurityAnswerAndPhoneModel ) . Result ;
该接口用于通过安全问题重置指定账户的密码 更多信息
ResetPasswordBySecurityAnswerAndUserNameModel resetPasswordBySecurityAnswerAndUserNameModel = new ResetPasswordBySecurityAnswerAndUserNameModel {
Password = "<Password>" ,
SecurityAnswer = new Dictionary < String , String > {
[ "QuestionID" ] = "Answer"
} ,
UserName = "<UserName>"
} ; //Required
var apiResponse = new AuthenticationApi ( ) . ResetPasswordBySecurityAnswerAndUserName ( resetPasswordBySecurityAnswerAndUserNameModel ) . Result ;
该接口用于为指定账户设置新密码。更多信息
ResetPasswordByResetTokenModel resetPasswordByResetTokenModel = new ResetPasswordByResetTokenModel {
Password = "<Password>" ,
ResetToken = "<ResetToken>"
} ; //Required
var apiResponse = new AuthenticationApi ( ) . ResetPasswordByResetToken ( resetPasswordByResetTokenModel ) . Result ;
该接口用于为指定账户设置新密码。更多信息
ResetPasswordByEmailAndOtpModel resetPasswordByEmailAndOtpModel = new ResetPasswordByEmailAndOtpModel {
Email = "<Email>" ,
Otp = "<Otp>" ,
Password = "<Password>"
} ; //Required
var apiResponse = new AuthenticationApi ( ) . ResetPasswordByEmailOTP ( resetPasswordByEmailAndOtpModel ) . Result ;
如果您使用用户名作为工作流程中的唯一标识符,则此 API 用于为指定帐户设置新密码更多信息
ResetPasswordByUserNameModel resetPasswordByUserNameModel = new ResetPasswordByUserNameModel {
Otp = "<Otp>" ,
Password = "<Password>" ,
UserName = "<UserName>"
} ; //Required
var apiResponse = new AuthenticationApi ( ) . ResetPasswordByOTPAndUserName ( resetPasswordByUserNameModel ) . Result ;
该接口用于根据原密码修改账户密码 更多信息
var accessToken = "accessToken" ; //Required
var newPassword = "newPassword" ; //Required
var oldPassword = "oldPassword" ; //Required
var apiResponse = new AuthenticationApi ( ) . ChangePassword ( accessToken , newPassword , oldPassword ) . Result ;
此 API 用于根据访问令牌和社交提供商用户访问令牌将社交提供商帐户与指定帐户链接起来。更多信息
var accessToken = "accessToken" ; //Required
var candidateToken = "candidateToken" ; //Required
var apiResponse = new AuthenticationApi ( ) . LinkSocialIdentities ( accessToken , candidateToken ) . Result ;
此 API 用于根据 ping 和社交提供商用户访问令牌将社交提供商帐户与现有 LoginRadius 帐户链接起来。更多信息
var accessToken = "accessToken" ; //Required
var clientGuid = "clientGuid" ; //Required
var apiResponse = new AuthenticationApi ( ) . LinkSocialIdentitiesByPing ( accessToken , clientGuid ) . Result ;
该API用于通过访问令牌设置或更改用户名。更多信息
var accessToken = "accessToken" ; //Required
var username = "username" ; //Required
var apiResponse = new AuthenticationApi ( ) . SetOrChangeUserName ( accessToken , username ) . Result ;
该API将验证电子邮件重新发送给用户。更多信息
var email = "email" ; //Required
var emailTemplate = "emailTemplate" ; //Optional
var verificationUrl = "verificationUrl" ; //Optional
var apiResponse = new AuthenticationApi ( ) . AuthResendEmailVerification ( email , emailTemplate , verificationUrl ) . Result ;
此 API 用于向用户帐户添加其他电子邮件。更多信息
var accessToken = "accessToken" ; //Required
var email = "email" ; //Required
var type = "type" ; //Required
var emailTemplate = "emailTemplate" ; //Optional
var verificationUrl = "verificationUrl" ; //Optional
var apiResponse = new AuthenticationApi ( ) . AddEmail ( accessToken , email , type , emailTemplate , verificationUrl ) . Result ;
此 API 根据电子邮件更多信息检索用户数据的副本
EmailAuthenticationModel emailAuthenticationModel = new EmailAuthenticationModel {
Email = "<Email>" ,
Password = "<Password>"
} ; //Required
var emailTemplate = "emailTemplate" ; //Optional
string fields = null ; //Optional
var loginUrl = "loginUrl" ; //Optional
var verificationUrl = "verificationUrl" ; //Optional
var apiResponse = new AuthenticationApi ( ) . LoginByEmail ( emailAuthenticationModel , emailTemplate , fields , loginUrl , verificationUrl ) . Result ;
此 API 根据用户名检索用户数据的副本 更多信息
UserNameAuthenticationModel userNameAuthenticationModel = new UserNameAuthenticationModel {
Password = "<Password>" ,
Username = "<Username>"
} ; //Required
var emailTemplate = "emailTemplate" ; //Optional
string fields = null ; //Optional
var loginUrl = "loginUrl" ; //Optional
var verificationUrl = "verificationUrl" ; //Optional
var apiResponse = new AuthenticationApi ( ) . LoginByUserName ( userNameAuthenticationModel , emailTemplate , fields , loginUrl , verificationUrl ) . Result ;
该接口用于向指定账户发送重置密码url。注意:如果您启用了“用户名”工作流程,则可以将“电子邮件”参数替换为“用户名”更多信息
var email = "email" ; //Required
var resetPasswordUrl = "resetPasswordUrl" ; //Required
var emailTemplate = "emailTemplate" ; //Optional
var apiResponse = new AuthenticationApi ( ) . ForgotPassword ( email , resetPasswordUrl , emailTemplate ) . Result ;
此 API 在数据库中创建用户并向用户发送验证电子邮件。更多信息