
Introducing @hazeljs/oauth: One Package for Google, Microsoft, GitHub, Facebook & Twitter Login
Add social login to your HazelJS apps in minutes—not hours. Building OAuth from scratch is painful. Authorization URLs, state validation, PKCE for some providers, token exchange, user profile fetching—each provider has its own quirks. We built @hazeljs/oauth so you can add "Sign in with Google" (and four other providers) with a single package and a few lines of config. The Problem with DIY OAuth If you've ever implemented OAuth yourself, you know the drill: Provider-specific flows — Google and Microsoft require PKCE; GitHub and Facebook don't. Twitter uses OAuth 2.0 with different scopes. State management — You need to generate, store, and validate a cryptographically secure state to prevent CSRF. For PKCE providers, you also store a code_verifier . Token exchange — Exchange the authorization code for tokens. Handle errors. Parse responses. User profile — Each provider has a different API: Google's userinfo , Microsoft Graph /me , GitHub /user , Facebook Graph /me , Twitter API v2 /use
Continue reading on Dev.to Webdev
Opens in a new tab




