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 在資料庫中建立使用者並向使用者發送驗證電子郵件。更多資訊