# Authing - CSharp
The Authing C# SDK consists of two parts: ManagementClient
and AuthenticationClient
. All operations performed in ManagementClient
are performed as an administrator, including modules such as managing users, managing roles, managing authority policies, and managing user pool configuration. All operations in AuthenticationClient
are performed as the current terminal user, including methods such as login, register, modify user information, and log out.
You should set the initialized ManagementClient
instance to a global variable (initialize only once), and AuthenticationClient
should be initialized one for every request.
# Installation
Install via Nuget:
Install-Package Authing.ApiClient
# Using the management module
Initializing ManagementClient
requires userPoolId
(user pool ID) and secret
(user pool key):
You can click here Learn how to get UserPoolId and Secret (opens new window).
using Authing.ApiClient;
var managementClient = new ManagementClient("AUTHING_USERPOOL_ID", "AUTHING_USERPOOL_SECRET");
Now the ManagementClient()
instance is ready to use. For example, you can get the list of users in the user pool:
var managementClient = new ManagementClient("AUTHING_USERPOOL_ID", "AUTHING_USERPOOL_SECRET");
var data = await managementClient.Users.List();
# Use authentication module
Initializing ManagementClient
requires userPoolId
(user pool ID):
You can learn how to get UserPoolId (opens new window) here.
using Authing.ApiClient;
var authenticationClient = new AuthenticationClient("AUTHING_USERPOOL_ID");
Then you can register and log in and other operations:
var username = GetRandomString(10);
var password = GetRandomString(10);
var user = await authenticationClient.loginByUsername(
username,
password,
)
After logging in, methods such as update_profile
that require users to log in are available:
await authenticationClient.UpdateProfile(new UpdateUserInput() {
Nickname = "Nick",
})
You can also set the AccessToken
parameter after initialization, without calling the LoginByXXX
method every time:
using Authing.ApiClient;
var authenticationClient = new AuthenticationClient("AUTHING_USERPOOL_ID");
authenticationClient.AccessToken = "access token";
Execute the UpdateProfile
method again and find that it is also successful:
await authenticationClient.UpdateProfile(new UpdateUserInput() {
Nickname = "Nick",
})
# Error handling
# Get help
Join us on Gitter: #authing-chat (opens new window)
# Interface Index
Available Authentication methods
- Get the user information of the current user:
CurrentUser
- Register by email:
RegisterByEmail
- Register with username:
RegisterByUsername
- Use mobile phone number verification code to register:
RegisterByPhoneCode
- Login with email:
LoginByEmail
- Login with username:
LoginByUsername
- Use the mobile phone number verification code to log in to
LoginByPhoneCode
- Login with mobile phone number password:
LoginByPhonePassword
- Send email:
SendEmail
- Send SMS verification code:
SendSmsCode
- Check the valid status of the token:
CheckLoginStatus
- Use phone number verification code to reset password:
ResetPasswordByPhoneCode
- Use email verification code to reset password:
ResetPasswordByEmailCode
- Update user profile:
UpdateProfile
- Update password:
UpdatePassword
- Update phone number:
UpdatePhone
- Update email:
UpdateEmail
- Refresh token:
RefreshToken
- Bind mobile phone number:
BindPhone
- Unbind phone number:
UnbindPhone
- Add current user-defined field value:
SetUdv
- Get the current user's custom field value:
ListUdv
- Delete the current user-defined field value:
RemoveUdv
For details, see:
Core Authentication ModuleThe management module contains the following sub-modules:
Manage users Manage Roles Manage Strategy Manage Authority & Access Control Manage Groups Manage custom field metadata Manage user pool configuration Manage registration whitelist