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
#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

Myvas.AspNetCore.Authentication Family

QQConnect WeixinOpen WeixinAuth

  • QQConnect: Here
  • WeixinOpen: Here
  • WeixinAuth: this repo

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 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
7.0.11 130 9/17/2023
6.0.3 536 3/25/2022
6.0.2.20222 422 2/22/2022
3.1.3.3 601 4/10/2020
3.1.0.2 611 12/14/2019
3.1.0.1 502 12/13/2019
2.2.1027 480 10/24/2019
2.1.508 768 4/6/2019
2.1.506 544 3/30/2019
2.1.504 713 3/10/2019
2.1.414 757 10/15/2018