Nedo.AspNet.Authentication.Facebook
2.0.9
dotnet add package Nedo.AspNet.Authentication.Facebook --version 2.0.9
NuGet\Install-Package Nedo.AspNet.Authentication.Facebook -Version 2.0.9
<PackageReference Include="Nedo.AspNet.Authentication.Facebook" Version="2.0.9" />
<PackageVersion Include="Nedo.AspNet.Authentication.Facebook" Version="2.0.9" />
<PackageReference Include="Nedo.AspNet.Authentication.Facebook" />
paket add Nedo.AspNet.Authentication.Facebook --version 2.0.9
#r "nuget: Nedo.AspNet.Authentication.Facebook, 2.0.9"
#:package Nedo.AspNet.Authentication.Facebook@2.0.9
#addin nuget:?package=Nedo.AspNet.Authentication.Facebook&version=2.0.9
#tool nuget:?package=Nedo.AspNet.Authentication.Facebook&version=2.0.9
Nedo.AspNet.Authentication.Facebook
"Sign in with Facebook" — your app mints its own JWTs after verifying a Facebook access token via the Graph API. The SPA uses the Facebook JS SDK to obtain the access token and POSTs it to your API.
Install
dotnet add package Nedo.AspNet.Authentication.Facebook
Quickstart
using Nedo.AspNet.Authentication.Facebook;
builder.Services.AddFacebook(opts =>
{
opts.AppId = builder.Configuration["Facebook:AppId"]!;
opts.AppSecret = builder.Configuration["Facebook:AppSecret"]!; // used for app-secret-proof
});
var app = builder.Build();
app.MapLocalAuth();
app.MapLocalAccount();
app.MapFacebookAuth(); // POST /auth/facebook { accessToken, intent? }
Frontend (SPA)
<script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js"></script>
FB.init({ appId: import.meta.env.VITE_FACEBOOK_APP_ID, version: 'v18.0' });
FB.login(async (response) => {
if (response.status !== 'connected') return;
const tokens = await fetch('/auth/facebook', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ accessToken: response.authResponse.accessToken, intent: 'signin' }),
}).then(r => r.json());
}, { scope: 'email' });
App-secret-proof
The backend computes appsecret_proof = HMAC-SHA256(accessToken, AppSecret) and includes it on the me Graph API call. This is Facebook's recommended hardening against access-token theft — even an attacker who steals the token can't query the Graph API without the secret.
Console setup
- https://developers.facebook.com/apps/ → Create App → Consumer.
- Add the Facebook Login product → Settings → add your SPA origin to Valid OAuth Redirect URIs (even though the JS SDK handles redirects; Facebook still validates the origin).
- App Settings → Basic → copy App ID + App Secret.
Full walkthrough: docs/providers/social/facebook.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.9)
- Nedo.AspNet.Authentication.Local (>= 2.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.