Nedo.AspNet.Authentication.GitHub 2.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Nedo.AspNet.Authentication.GitHub --version 2.0.2
                    
NuGet\Install-Package Nedo.AspNet.Authentication.GitHub -Version 2.0.2
                    
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="Nedo.AspNet.Authentication.GitHub" Version="2.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nedo.AspNet.Authentication.GitHub" Version="2.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Nedo.AspNet.Authentication.GitHub" />
                    
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 Nedo.AspNet.Authentication.GitHub --version 2.0.2
                    
#r "nuget: Nedo.AspNet.Authentication.GitHub, 2.0.2"
                    
#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 Nedo.AspNet.Authentication.GitHub@2.0.2
                    
#: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=Nedo.AspNet.Authentication.GitHub&version=2.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Nedo.AspNet.Authentication.GitHub&version=2.0.2
                    
Install as a Cake Tool

Nedo.AspNet.Authentication.GitHub

"Sign in with GitHub" — backend OAuth code-exchange flow with a popup + postMessage round-trip back to the SPA. Supports github.com and self-hosted GitHub Enterprise Server. Your app mints its own JWTs after verifying the GitHub identity.

Install

dotnet add package Nedo.AspNet.Authentication.GitHub

Quickstart

using Nedo.AspNet.Authentication.GitHub;

builder.Services.AddGitHub(opts =>
{
    opts.ClientId       = builder.Configuration["GitHub:ClientId"]!;
    opts.ClientSecret   = builder.Configuration["GitHub:ClientSecret"]!;
    opts.FrontendOrigin = "https://app.example.com";   // popup → postMessage target
});

var app = builder.Build();
app.MapLocalAuth();
app.MapLocalAccount();
app.MapGitHubAuth();
// → GET /auth/github/start?intent=signin     opens GitHub authorize page in popup
// → GET /auth/github/callback                exchanges code, mints session, postMessage's
//                                            the result back to opener and closes the popup

Frontend (SPA)

The popup flow is fully backend-driven — the SPA just opens the URL and listens for the postMessage:

const popup = window.open(`${API}/auth/github/start?intent=signin`, 'github-signin', 'width=500,height=700');

window.addEventListener('message', (e) => {
    if (e.origin !== API_ORIGIN) return;
    if (e.data?.type !== 'oauth-result') return;
    if (e.data.ok) {
        // e.data.payload is TokenResponse | PendingProfile
        // …
    } else {
        // e.data.payload is { code, message }
    }
}, { once: true });

The popup closes itself after posting the result.

GitHub Enterprise Server

opts.ServerUrl = "https://github.mycorp.example.com";   // omit for github.com

Everything else is identical. The package builds the OAuth URLs from ServerUrl and validates the resulting access token against the same instance.

Console setup

  1. https://github.com/settings/developersOAuth Apps → New OAuth App.
  2. Authorization callback URLhttps://api.example.com/auth/github/callback (and http://localhost:5050/auth/github/callback for dev).
  3. Copy the Client ID + generate a Client Secret.

For Enterprise Server, register the OAuth app under that instance's Settings → Developer settings.

Full walkthrough: docs/providers/social/github.md.

License

MIT — see LICENSE.

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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
2.0.9 96 5/11/2026
2.0.8 86 5/6/2026
2.0.7 86 5/5/2026
2.0.6 90 5/5/2026
2.0.4 84 5/4/2026
2.0.3 84 5/4/2026
2.0.2 92 5/2/2026
2.0.1 82 5/2/2026
2.0.0 92 5/1/2026