Nedo.AspNet.Authentication.GitHub
2.0.7
See the version list below for details.
dotnet add package Nedo.AspNet.Authentication.GitHub --version 2.0.7
NuGet\Install-Package Nedo.AspNet.Authentication.GitHub -Version 2.0.7
<PackageReference Include="Nedo.AspNet.Authentication.GitHub" Version="2.0.7" />
<PackageVersion Include="Nedo.AspNet.Authentication.GitHub" Version="2.0.7" />
<PackageReference Include="Nedo.AspNet.Authentication.GitHub" />
paket add Nedo.AspNet.Authentication.GitHub --version 2.0.7
#r "nuget: Nedo.AspNet.Authentication.GitHub, 2.0.7"
#:package Nedo.AspNet.Authentication.GitHub@2.0.7
#addin nuget:?package=Nedo.AspNet.Authentication.GitHub&version=2.0.7
#tool nuget:?package=Nedo.AspNet.Authentication.GitHub&version=2.0.7
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
- https://github.com/settings/developers → OAuth Apps → New OAuth App.
- Authorization callback URL —
https://api.example.com/auth/github/callback(andhttp://localhost:5050/auth/github/callbackfor dev). - 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 | Versions 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. |
-
net9.0
- Nedo.AspNet.Authentication (>= 2.0.7)
- Nedo.AspNet.Authentication.Local (>= 2.0.7)
- Nedo.AspNet.Authentication.Oidc (>= 2.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.