# CollectiveOAuth **Repository Path**: rthinking/CollectiveOAuth ## Basic Information - **Project Name**: CollectiveOAuth - **Description**: .Net平台(C#) 史上最全的整合第三方登录目前已包含Github、Gitee、钉钉、百度、支付宝、微信、企业微信、微博、QQ、Google、Facebook、抖音、领英、小米、微软、今日头条、Teambition、StackOverflow、Pinterest、人人、华为、酷家乐、Gitlab、美团、饿了么、等第三方平台的授权登录。以下平台正在接入中: 推特、淘宝 - **Primary Language**: C# - **License**: AGPL-3.0 - **Default Branch**: master - **Homepage**: https://geekoutnet.github.io/CollectiveOAuth - **GVP Project**: No ## Statistics - **Stars**: 975 - **Forks**: 320 - **Created**: 2020-01-28 - **Last Updated**: 2026-10-23 ## Categories & Tags **Categories**: oauth-dev **Tags**: None ## README

CollectiveOAuth

Third-party OAuth login for .NET
One API for 31 providers, including WeChat, Alipay, DingTalk, QQ, GitHub, Google and Microsoft

Docs .NET Framework 4.6.2+ .NET Standard 2.0 .NET 8 AGPL-3.0

Documentation (Chinese) · 中文

--- ## Overview CollectiveOAuth hides the protocol differences between OAuth providers. Every provider is used the same way: ```text your app ──authorize()──▶ provider consent page ──callback──▶ login() ──▶ AuthUser ``` The library is a C# implementation of [JustAuth](https://github.com/justauth/JustAuth) 1.16.7. For every provider, the authorization URL, the outgoing HTTP requests and the parsed user are verified against JustAuth by automated differential tests. ## Features - **31 providers**: WeChat (Official Account, Open Platform, WeCom), Alipay, DingTalk, QQ, Weibo, Douyin, Huawei, Taobao, GitHub, GitLab, Google, Microsoft, Facebook, Twitter, LinkedIn, Stack Overflow and more. - **One model for all providers**: `ClientConfig`, `AuthCallback`, `AuthResponse` and `AuthUser` are shared; switching providers means switching the request class. - **Secure defaults**: `state` is single-use (CSRF and replay protection), and query parameters are URL-encoded. - **Multi-instance ready**: `DistributedAuthStateCache` works with any `IDistributedCache`, such as Redis. - **Configurable networking**: per-provider timeout and proxy; HTTP errors include the status code and response body. - **Targets** .NET Framework 4.6.2+, .NET Standard 2.0 and .NET 8. ## Installation The library is currently consumed from source: ```bash git clone https://github.com/geekoutnet/CollectiveOAuth.git dotnet add .csproj reference CollectiveOAuth/Come.CollectiveOAuth/Come.CollectiveOAuth.csproj ``` ## Quick start (ASP.NET Core, GitHub) ```csharp // Program.cs builder.Services.AddDistributedMemoryCache(); builder.Services.AddSingleton(); ``` ```csharp var config = new ClientConfig { clientId = "", clientSecret = "", redirectUri = "https://your.site/oauth2/callback/github" }; // Redirect the user to the consent page var request = new GithubAuthRequest(config, authStateCache); return Redirect(request.authorize(AuthStateUtils.createState())); // In the callback action AuthResponse response = request.login(callback); if (response.ok()) { var user = (AuthUser)response.data; } ``` ## Supported providers `WECHAT_MP`, `WECHAT_OPEN`, `WECHAT_ENTERPRISE`, `WECHAT_ENTERPRISE_SCAN`, `ALIPAY_MP`, `DINGTALK_SCAN`, `QQ`, `WEIBO`, `BAIDU`, `GITEE`, `OSCHINA`, `CODING`, `XIAOMI`, `HUAWEI`, `DOUYIN`, `TOUTIAO`, `MEITUAN`, `ELEME`, `TAOBAO`, `KUJIALE`, `TEAMBITION`, `RENREN`, `GITHUB`, `GITLAB`, `GOOGLE`, `MICROSOFT`, `FACEBOOK`, `LINKEDIN`, `TWITTER`, `PINTEREST`, `STACK_OVERFLOW`. See the [Chinese README](README.md#支持的平台) for request classes and links to each provider's documentation. ## Development ```bash dotnet build Come.CollectiveOAuth/Come.CollectiveOAuth.csproj dotnet test Come.CollectiveOAuth.Tests ``` Golden files in `Come.CollectiveOAuth.Tests/Golden` are produced by running JustAuth 1.16.7 through [tools/justauth-golden](tools/justauth-golden); the C# tests replay the same inputs and compare the results. ## License [AGPL-3.0](LICENSE)