CollectiveOAuthCore 1.1.0

dotnet add package CollectiveOAuthCore --version 1.1.0
                    
NuGet\Install-Package CollectiveOAuthCore -Version 1.1.0
                    
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="CollectiveOAuthCore" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CollectiveOAuthCore" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="CollectiveOAuthCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CollectiveOAuthCore --version 1.1.0
                    
#r "nuget: CollectiveOAuthCore, 1.1.0"
                    
#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.
#:package CollectiveOAuthCore@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CollectiveOAuthCore&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=CollectiveOAuthCore&version=1.1.0
                    
Install as a Cake Tool

CollectiveOAuthCore

NuGet License

CollectiveOAuthCore is a third-party login (OAuth2 / OIDC) integration library for ASP.NET Core. It wraps the authorization flows of 30+ domestic and international platforms behind a unified AuthRequest API, so you can add social login to your app with just a few lines of code.

.NET 平台下的第三方授权登录工具类库,封装主流平台 OAuth2 / OIDC 流程,统一返回 AuthUser,让第三方登录接入 So easy!


Features

  • Wide coverage – 30+ platforms (GitHub, Google, Microsoft, LinkedIn, Facebook, Weibo, QQ, WeChat Open/MP/Enterprise, Alipay, Gitee, GitLab, Baidu, XiaoMi, Huawei, Douyin, Meituan, Eleme …).
  • Simple API – one authorize(state) + login(callback) flow for every platform.
  • Unified model – AuthUser with uuid / nickname / avatar / email / token / source.
  • State anti-replay – built-in IAuthStateCache, customizable (e.g. Redis for multi-instance).
  • Async & DI friendly – loginAsync / refreshAsync / revokeAsync, injectable HttpClient.
  • Multi-target – net8.0, net9.0, net10.0.

Installation

dotnet add package CollectiveOAuthCore

Quick Start

1. Configure a client

using Come.CollectiveOAuth.Config;

var config = new ClientConfig
{
    clientId     = "your-client-id",
    clientSecret = "your-client-secret",
    redirectUri  = "https://your-domain.com/callback/github",
    scope        = "user:email"
};

2. Redirect to the authorization page

using Come.CollectiveOAuth.Request;
using Come.CollectiveOAuth.Utils;

var request = new GithubAuthRequest(config);
string state = AuthStateUtils.createState();
return Redirect(request.authorize(state));

3. Handle the callback

public IActionResult Callback(AuthCallback callback)
{
    var request = new GithubAuthRequest(config); // same cache instance as step 2
    AuthResponse response = request.login(callback);
    if (response.ok())            // code == 2000 means success
    {
        AuthUser user = (AuthUser)response.data;
        // user.uuid / user.nickname / user.avatar / user.email / user.token
    }
    return View();
}

Note: authorize and login must share the same IAuthStateCache instance; otherwise state validation fails on callback. The default DefaultAuthStateCache uses in-process IMemoryCache (fine for single-instance). For multi-instance deployments, inject a shared cache (Redis, etc.) implementing IAuthStateCache.

Supported Platforms

authSource Platform Notes
GITHUB GitHub default scope user:email
GOOGLE Google OIDC
MICROSOFT Microsoft needs offline_access for refresh token
LINKEDIN LinkedIn OpenID Connect (openid profile email)
FACEBOOK Facebook sensitive fields need App Review
WEIBO 微博 —
QQ QQ unionId available with extra permission
WECHAT_OPEN / WECHAT_MP / WECHAT_ENTERPRISE / WECHAT_ENTERPRISE_SCAN WeChat Open / MP / Enterprise
ALIPAY_MP Alipay requires alipayPublicKey
GITEE / OSCHINA / CODING / GITLAB Code hosting —
BAIDU / XIAOMI / HUAWEI / KUJIALE Domestic vendors —
DOUYIN / TOUTIAO ByteDance —
MEITUAN / ELEME Meituan / Eleme —
STACK_OVERFLOW / PINTEREST / RENREN / TEAMBITION Others —

Namespaces

using Come.CollectiveOAuth.Config;
using Come.CollectiveOAuth.Models;
using Come.CollectiveOAuth.Request;
using Come.CollectiveOAuth.Utils;
using Come.CollectiveOAuth.Cache;

More

  • Full docs (中文): see 使用文档.md / 使用文档.en.md shipped with the source.
  • Sample: Come.AspNetCore.Sample for a complete ASP.NET Core demo.
  • Source: https://gitee.com/izory/CollectiveOAuth

License

MIT — see LICENSE.

Inspired by the JustAuth project.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
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
1.1.0 43 9/30/2026
1.0.1 284 1/5/2025
1.0.1-alpha 204 1/4/2025
1.0.0 226 5/29/2024
1.0.0-alpha 175 5/29/2024