{"repo":"tasoskakour/react-use-oauth2","free":true,"listed":false,"github":"https://github.com/tasoskakour/react-use-oauth2","clone":"git clone https://github.com/tasoskakour/react-use-oauth2.git","description":"💎 A React hook that handles OAuth2 authorization. Both for Implicit Grant and Authorization Code flows.","language":"TypeScript","stars":61,"topics":["oauth2","hooks","react"],"license":"MIT","category":"auth-billing-email","readme_excerpt":"@tasoskakour/react-use-oauth2 💎 A custom React hook that makes OAuth2 authorization simple — supporting both Authorization Code and Implicit Grant flows. --- ✨ Features - Supports Authorization Code and Implicit Grant flows. - Exchanges code for token via your backend automatically (for Authorization Code flow). - Handles popup-based authorization. - Provides data , loading , and error states. - Persists auth state to localStorage and syncs across tabs . --- 📦 Installation Requires react@18 or higher. --- 🚀 Usage Example Authorization Code Flow Example: --- 📚 Concepts 🔹 What is exchangeCodeForTokenQuery ? When using the Authorization Code flow, after receiving an authorization code , you must exchange it for an access token . You typically do this server-side because it requires your OAuth client secret. The exchangeCodeForTokenQuery object lets you specify: - url : Your backend endpoint that performs the code-to-token exchange. - method : HTTP method (default: POST ). - headers : Optional custom headers. The backend must call the OAuth provider's token endpoint securely. More about exchanging authorization codes ➡️ (Google docs) --- 🔹 Alternative: exchangeCodeForTokenQueryFn If you need full control (e.g., sending application/x-www-form-urlencoded body), you can use exchangeCodeForTokenQueryFn , a custom async function that manually exchanges the code. --- 🔹 What about Implicit Grant flows? In an Implicit Grant ( responseType: 'token' ), the 3rd-party provider sends b","default_branch":null,"files":null,"tree":[],"storefront":"/r/tasoskakour","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/tasoskakour/react-use-oauth2/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}