You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.5 KiB
2.5 KiB
LINGYUN.Abp.Authentication.WeChat
WeChat Official Account authentication module, integrating WeChat Official Account login functionality into ABP applications.
Features
- WeChat Official Account OAuth2.0 authentication
- Retrieve WeChat user information (nickname, gender, region, avatar, etc.)
- Support for UnionId mechanism, connecting Official Account and Mini Program account systems
- Support for WeChat server message verification
- Integration with ABP identity system
Module Dependencies
[DependsOn(typeof(AbpAuthenticationWeChatModule))]
public class YouProjectModule : AbpModule
{
// other
}
Configuration
{
"Authentication": {
"WeChat": {
"AppId": "Your WeChat Official Account AppId",
"AppSecret": "Your WeChat Official Account AppSecret",
"ClaimsIssuer": "WeChat", // Optional, defaults to WeChat
"CallbackPath": "/signin-wechat", // Optional, defaults to /signin-wechat
"Scope": ["snsapi_login", "snsapi_userinfo"], // Optional, defaults to snsapi_login and snsapi_userinfo
"QrConnect": {
"Enabled": false, // Enable PC-side QR code login
"Endpoint": "https://open.weixin.qq.com/connect/qrconnect" // PC-side QR code login endpoint
}
}
}
}
Basic Usage
-
Configure WeChat Official Account Parameters
- Register an Official Account on WeChat Official Account Platform to get AppId and AppSecret
- Configure AppId and AppSecret in appsettings.json
-
Add WeChat Login
public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddAuthentication() .AddWeChat(); // Add WeChat login support } -
Enable WeChat Server Message Verification (Optional)
public void Configure(IApplicationBuilder app) { app.UseWeChatSignature(); // Enable WeChat server message verification middleware }
Retrieved User Information
- OpenId - Unique WeChat user identifier
- UnionId - WeChat Open Platform unique identifier (requires binding to Open Platform)
- NickName - User's nickname
- Sex - User's gender
- Country - User's country
- Province - User's province
- City - User's city
- AvatarUrl - User's avatar URL
- Privilege - User's privilege information