Myvas.AspNetCore.Authentication.WeixinAuth
7.0.11
dotnet add package Myvas.AspNetCore.Authentication.WeixinAuth --version 7.0.11
NuGet\Install-Package Myvas.AspNetCore.Authentication.WeixinAuth -Version 7.0.11
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Myvas.AspNetCore.Authentication.WeixinAuth" Version="7.0.11" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Myvas.AspNetCore.Authentication.WeixinAuth --version 7.0.11
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Myvas.AspNetCore.Authentication.WeixinAuth, 7.0.11"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Myvas.AspNetCore.Authentication.WeixinAuth as a Cake Addin
#addin nuget:?package=Myvas.AspNetCore.Authentication.WeixinAuth&version=7.0.11
// Install Myvas.AspNetCore.Authentication.WeixinAuth as a Cake Tool
#tool nuget:?package=Myvas.AspNetCore.Authentication.WeixinAuth&version=7.0.11
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Myvas.AspNetCore.Authentication Family
What's this?
An ASP.NET Core authentication middleware for https://mp.weixin.qq.com (微信公众平台/网页授权登录)
- 须微信公众平台(mp.weixin.qq.com)已认证的服务号(或测试号)。
- 用户可在微信客户端访问网站时自动登入网站。换而言之,用户在微信客户端中访问网页时,可以通过此组件Challenge获取用户的OpenId或UnionId,据此可以识别用户。
How to Use?
0.Create account
(1)在微信公众平台(https://mp.weixin.qq.com)上创建账号。
微信公众平台/网页授权获取用户信息,须在微信公众平台(mp.weixin.qq.com)上开通服务号,并认证。
注意:订阅号无网页授权权限,即使是已认证的订阅号也不行!
(2)配置功能权限:微信公众平台-已认证服务号/开发/接口权限/...
- 开通功能:网页服务/网页授权获取用户基本信息。
- 设置网页授权域名:例如,auth.myvas.com。
- 将文件MP_verify_xxxxxxxxx.txt上传至
wwwroot
目录下。
(3)当然,也可以在公众平台测试号上测试:微信公众平台-测试账号/开发/开发者工具/公众平台测试号/...
- 开通功能:网页服务/网页授权获取用户基本信息。
- 设置授权回调页面域名:例如,auth.myvas.com。
1.nuget
2.Configure
app.UseAuthentication();
3.ConfigureServices
services.AddAuthentication()
// using Myvas.AspNetCore.Authentication;
.AddWeixinAuth(options =>
{
options.AppId = Configuration["WeixinAuth:AppId"];
options.AppSecret = Configuration["WeixinAuth:AppSecret"];
options.SilentMode = false; // default is true
};
说明:
(1)同一用户在同一微信公众号即使重复多次订阅/退订,其OpenId也不会改变。
(2)同一用户在不同微信公众号中的OpenId是不一样的。
(3)若同时运营了多个微信公众号,可以在微信开放平台上开通开发者账号,并在“管理中心/公众账号”中将这些公众号添加进去,就可以获取到同一用户在这些公众号中保持一致的UnionId。
Dev
Demo
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.1 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 3.1
- Microsoft.AspNetCore.Authentication.Twitter (>= 3.1.3)
-
net5.0
- Microsoft.AspNetCore.Authentication.Twitter (>= 5.0.0)
-
net6.0
- Microsoft.AspNetCore.Authentication.Twitter (>= 6.0.0)
-
net7.0
- Microsoft.AspNetCore.Authentication.Twitter (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.