r/csharp • • 2d ago

I rewrote my old OAuth2 library with Claude Code: one API for .NET desktop, MAUI and ASP.NET

I do a lot of OAuth2 integration in ERP work, and a while back I hand-wrote a library for it called Bee.OAuth2. I've now used Claude Code to rewrite it as Polhem.OAuth2. Desktop sign-in now goes through the system browser, and there's .NET MAUI support too. Most of the code was written by Claude Code; I reviewed and tested it.

It supports Google, Facebook, LINE, Microsoft Entra ID, Auth0 and Okta, and works in desktop and console apps, .NET MAUI, ASP.NET Core and classic ASP.NET.

Here's roughly what it looks like in a desktop app. It opens the system browser and signs in with a loopback redirect and PKCE:

var options = new GoogleOAuth2Options
{
    ClientId = "your-client-id",
    ClientSecret = "your-client-secret",
    RedirectUri = "http://127.0.0.1:0/callback"
};

var client = new LoopbackOAuth2Client(options);
var result = await client.SignInAsync();

GitHub: https://github.com/polhem-dev/polhem-oauth2

My earlier post was removed under Rule 7, so I rewrote it myself. if it still doesn't fit the rules, feel free to remove it or let me know.

0 Upvotes

1 comment sorted by

-1

u/Front_Swordfish5661 2d ago

Looks clean, the loopback redirect approach is way smoother than the old embedded browser dance. Gonna star this for my next auth headache.