OAuth2 1.0.0

dotnet add package OAuth2 --version 1.0.0
                    
NuGet\Install-Package OAuth2 -Version 1.0.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="OAuth2" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OAuth2" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="OAuth2" />
                    
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 OAuth2 --version 1.0.0
                    
#r "nuget: OAuth2, 1.0.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 OAuth2@1.0.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=OAuth2&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=OAuth2&version=1.0.0
                    
Install as a Cake Tool

OAuth2

Build CodeQL NuGet

OAuth2 is a library for user authentication using third-party services (OAuth/OAuth2 protocol) such as Google, Facebook and so on.

Standard Flow

  1. Generate a login URL and render a page with it
  2. Define a callback endpoint that the third-party service redirects to after successful authentication
  3. Retrieve user info on callback from the third-party service

Installation

Install the OAuth2 NuGet package:

dotnet add package OAuth2

Usage Example (ASP.NET Core Minimal API)

using System.Collections.Specialized;
using OAuth2.Client.Impl;
using OAuth2.Configuration;
using OAuth2.Infrastructure;

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

// Helper to create a GoogleClient instance
GoogleClient CreateGoogleClient()
{
    return new GoogleClient(new RequestFactory(), new ClientConfiguration
    {
        ClientId = app.Configuration["Google:ClientId"]!,
        ClientSecret = app.Configuration["Google:ClientSecret"]!,
        RedirectUri = "https://localhost:5001/auth/google/callback",
        Scope = "profile email"
    });
}

// Step 1: Redirect the user to Google's login page
app.MapGet("/auth/google", async () =>
{
    var client = CreateGoogleClient();
    var loginUri = await client.GetLoginLinkUriAsync();
    return Results.Redirect(loginUri);
});

// Step 2: Handle the callback after authentication
app.MapGet("/auth/google/callback", async (HttpContext context) =>
{
    var code = context.Request.Query["code"].ToString();
    if (string.IsNullOrEmpty(code))
        return Results.BadRequest("Missing authorization code.");

    var client = CreateGoogleClient();
    var userInfo = await client.GetUserInfoAsync(new NameValueCollection { { "code", code } });

    return Results.Ok(new
    {
        userInfo.Id,
        userInfo.FirstName,
        userInfo.LastName,
        userInfo.Email,
        AvatarUri = userInfo.AvatarUri?.ToString()
    });
});

app.Run();

Supported Services

Provider Client Class Status API Version Auth Endpoint Last Verified Docs
GitHub GitHubClient Active REST (default: 2022-11-28) github.com/login/oauth/authorize 2026-04-23 Docs
Google GoogleClient Active OAuth2 v2 / UserInfo v3 accounts.google.com/o/oauth2/v2/auth 2026-04-23 Docs
Facebook FacebookClient Active Graph API v25.0 www.facebook.com/v25.0/dialog/oauth 2026-04-23 Docs
Microsoft MicrosoftClient Active Identity Platform v2.0 / Graph v1.0 login.microsoftonline.com/common/oauth2/v2.0/authorize 2026-04-23 Docs
Asana AsanaClient Active API v1 app.asana.com/-/oauth_authorize 2026-04-23 Docs
DigitalOcean DigitalOceanClient Active OAuth 2.0 cloud.digitalocean.com/v1/oauth/authorize 2026-04-23 Docs
ExactOnline ExactOnlineClient Active REST API v1 start.exactonline.nl/api/oauth2/authorize 2026-04-23 Docs
Fitbit FitbitClient Active Web API v1 (user profile) www.fitbit.com/oauth2/authorize 2026-04-23 Docs
Foursquare FoursquareClient Deprecated v2 (OAuth deprecated) foursquare.com/oauth2/authorize 2026-04-23 Docs
LinkedIn LinkedInClient Active OAuth v2 (OpenID Connect) www.linkedin.com/oauth/v2/authorization 2026-04-23 Docs
LoginCidadao LoginCidadaoClient Unknown OpenID Connect v2 logincidadao.rs.gov.br/openid/connect/authorize 2026-04-23
MailRu MailRuClient Active OAuth 2.0 connect.mail.ru/oauth/authorize 2026-04-23 Docs
Odnoklassniki OdnoklassnikiClient Active OAuth 2.0 www.odnoklassniki.ru/oauth/authorize 2026-04-23 Docs
Salesforce SalesforceClient Active OAuth 2.0 (Web Server Flow) login.salesforce.com/services/oauth2/authorize 2026-04-23 Docs
Spotify SpotifyClient Active Web API v1 accounts.spotify.com/authorize 2026-04-23 Docs
Todoist TodoistClient Active REST API v1 app.todoist.com/oauth/authorize 2026-04-23 Docs
X (Twitter) XClient Active OAuth 1.0a / API v1.1 api.twitter.com/oauth/authenticate 2026-04-23 Docs
Uber UberClient Active OAuth v2 auth.uber.com/oauth/v2/authorize 2026-04-23 Docs
VK (Vkontakte) VkClient Active API v5.131 oauth.vk.com/authorize 2026-04-23 Docs
VSTS (Azure DevOps) VSTSClient Deprecated (2026) Azure DevOps OAuth (deprecated Apr 2025) app.vssps.visualstudio.com/oauth2/authorize 2026-04-23 Docs
Windows Live WindowsLiveClient Legacy (Working) Live SDK v5.0 login.live.com/oauth20_authorize.srf 2026-04-23 Migration Guide
Yahoo YahooClient Active OAuth 2.0 api.login.yahoo.com/oauth2/request_auth 2026-04-23 Docs
Yandex YandexClient Active OAuth 2.0 (Yandex ID) oauth.yandex.ru/authorize 2026-04-23 Docs

Removed providers (Instagram, Xing): These providers' APIs have been retired or shut down. The client classes have been removed.

  • Instagram: Basic Display API shut down Dec 4, 2024. There is no consumer OAuth replacement — the remaining Instagram APIs are business/creator-only. Announcement
  • Xing: OAuth 1.0a REST API discontinued. dev.xing.com only hosts plugins.

Renamed providers: TwitterClientXClient (Twitter rebranded to X). The old class name is preserved as an obsolete derived class that produces a compiler error directing users to the new name.

Legacy (Working): WindowsLiveClient — Microsoft officially retired the Live SDK in Nov 2018 but the endpoints continue to function in production. Confirmed working in Exceptionless. For new integrations, use MicrosoftClient (Microsoft Identity Platform v2.0 + Graph). User IDs differ between the two platforms.

Deprecated providers:

  • Foursquare: v2 consumer OAuth API deprecated. The replacement Places API v3 uses API keys, not OAuth.
  • VSTS (Azure DevOps): Azure DevOps OAuth stopped accepting new app registrations in April 2025 and is scheduled for full retirement in 2026. Use MicrosoftClient with Microsoft Entra ID OAuth instead

Goals

  • Simplicity in usage — even a newcomer can call a couple of methods and receive the expected result
  • Well-documented, testable, and tested code
  • Flexible, transparent, and easily understandable design
  • Support for both fine-grained control and simple plug-and-play usage

Dependencies

Contributors

  • Constantin Titarenko (started development, defined library structure, released initial version)
  • Blake Niemyjski (helped a lot to maintain the project, currently (since 2015) — top maintainer)
  • Andriy Somak (helped with improvements on configuration and extending the list of supported services)
  • Sascha Kiefer (simplified extending the library with own provider implementations, added GitHub client)
  • Krisztián Pócza (added LinkedIn (OAuth 2) client)
  • Jamie Houston (added a Todoist client)
  • Sasidhar Kasturi (added Uber, Spotify, Yahoo)
  • Jamie Dalton (added Visual Studio Team Services)

Acknowledgements

Many thanks to JetBrains company for providing free OSS licenses for ReSharper and dotCover - these tools allow us to work on this project with pleasure!

Also we glad to have opportunity to use free Teamcity CI server provided by Codebetter.com and JetBrains - many thanks for supporting OSS!

OAuth2 optimization would never be so simple without YourKit .NET profiler! We appreciate kind support of open source projects by YourKit LLC - the creator of innovative and intelligent tools for profiling .NET YourKit .NET Profiler and Java applications YourKit Java Profiler.

License

The MIT License (MIT) Copyright (c) 2012-2013 Constantin Titarenko, Andrew Semack and others

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on OAuth2:

Package Downloads
BotAuth.GenericOAuth2

This package is a generic OAuth2 authentication provider for using with the BotAuth package in a Bot Framework/BotBuilder Project.

TQLApp.Plugins.GitHub

Techie's Quick Launcher plugin for GitHub.

DashAPI

A client library for the Dash API's

Vern.Social

Vern Social

Vern.Social.Umbraco7

Social

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on OAuth2:

Repository Stars
exceptionless/Exceptionless
Exceptionless application
Version Downloads Last Updated
1.0.0 59 5/11/2026
1.0.0-beta1 213 4/24/2026
0.10.3 52,613 2/25/2023
0.10.2 64,869 10/18/2021
0.10.1 62,809 10/12/2020
0.10.0 3,205 9/2/2020
0.9.13-pre 32,102 11/8/2018
0.9.12-pre 44,827 1/9/2018
0.9.11-pre 2,802 11/10/2017
0.9.10-pre 2,347 11/7/2017
0.9.8-pre 2,311 10/6/2017
0.8.40 98,201 9/3/2016
0.8.38 2,342 8/31/2016
0.8.37 17,221 6/10/2016
0.8.36 14,895 10/22/2015
0.8.35 3,090 9/27/2015
0.8.34 26,675 7/31/2014
0.8.33 2,330 7/28/2014
0.8.32 2,620 6/30/2014
0.8.31 2,460 6/23/2014
Loading failed