Smallest .NET token validator using Authdog.Sdk. The package is
not on NuGet. Point this sample at a pinned checkout of
authdog/sdk. It takes a bearer
token you already have and resolves it against GET /v1/userinfo.
This SDK does not use a public key.
Authentication (authn): who the caller is, proven by validating an
access token. Authentication is not authorization. This sample does
not host sign-in; pair it with a framework SDK or your own callback
that obtains the token.
An access token to validate. Never ask for or embed the secret
key (sk_...). This core SDK is constructed with
https://api.authdog.com and does not take a pk_... public key.
.NET 8.0+ is required.
git clone https://github.com/authdog/sdk.git /tmp/authdog-sdk
git -C /tmp/authdog-sdk checkout 9b9ad52f4b23e5e0bdcffa6dc591ecdb08c7e180
export AUTHDOG_SDK=/tmp/authdog-sdk
dotnet run -- <access-token>Do not run dotnet add package Authdog.Sdk from nuget.org — that
package is not published.
dotnet run -- <valid-token>→ prints the userinfo user.dotnet run -- <bad-token>→ prints401 Unauthorizedand exits non-zero.
- Not on NuGet: set
AUTHDOG_SDKto a pinnedauthdog/sdkcheckout. Do not write a productiondotnet add package Authdog.Sdk. - This validates tokens, it doesn't issue them: obtain the token
from a framework SDK's callback or your own redirect handler before
calling
GetUserInfoAsync. - Dispose clients you own: this sample uses
await usingso theHttpClientis released. AuthenticationExceptionis the 401 path: a bad, expired, or revoked token is not a fabricated user.- Do not log access tokens.
- Bearer tokens go only to a trusted HTTPS identity host.
Authorization for this stack is Present: authz/csharp.
Apply
authorization
after GetUserInfoAsync. Do not treat a successful userinfo call as a
permission grant.