{"id":29011316,"url":"https://github.com/shekhardtu/oauthify","last_synced_at":"2025-06-25T17:12:15.698Z","repository":{"id":243354939,"uuid":"812206047","full_name":"shekhardtu/oauthify","owner":"shekhardtu","description":"The OAuthify library provides a seamless integration for adding OAuth-based login functionality into your React application. This package comes with pre-built headless components for Google and GitHub login buttons, making the OAuth flow implementation straightforward and efficient.","archived":false,"fork":false,"pushed_at":"2024-06-16T16:47:27.000Z","size":905,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-07T04:06:45.447Z","etag":null,"topics":["github-login-react","google-login-react","oauth2-client"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/oauthify","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shekhardtu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-08T08:32:13.000Z","updated_at":"2024-06-16T16:47:30.000Z","dependencies_parsed_at":"2024-06-12T00:04:18.415Z","dependency_job_id":null,"html_url":"https://github.com/shekhardtu/oauthify","commit_stats":null,"previous_names":["shekhardtu/react-oauth","shekhardtu/oauthify"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shekhardtu/oauthify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shekhardtu%2Foauthify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shekhardtu%2Foauthify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shekhardtu%2Foauthify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shekhardtu%2Foauthify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shekhardtu","download_url":"https://codeload.github.com/shekhardtu/oauthify/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shekhardtu%2Foauthify/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261917435,"owners_count":23229919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github-login-react","google-login-react","oauth2-client"],"created_at":"2025-06-25T17:12:13.927Z","updated_at":"2025-06-25T17:12:15.659Z","avatar_url":"https://github.com/shekhardtu.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### OAuthify\n\nThe OAuthify library provides a seamless integration for adding OAuth-based login functionality into your React application. This package comes with pre-built headless components for Google and GitHub login buttons, making the OAuth flow implementation straightforward and efficient.\n\n### Key Features\n\n- **Easy Integration:** Simplifies the addition of Google and GitHub login buttons to your React app.\n- **Secure Authentication:** Redirects users to the respective service's login page and securely handles the OAuth callback.\n- **Customizable:** Allows for custom handling of successful or failed logins, enabling you to tailor the user experience.\n\n\u003c!-- ![OAuthify Auth 2.0 headless Component](/src/assets/OAuthify.png) --\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"src/assets/OAuthify.png\" alt=\"OAuthify Auth 2.0 headless Component\" width=\"200\"\u003e\n\u003c/p\u003e\n\n### Installation\n\nTo install OAuthify, run:\n\n```bash\nnpm install oauthify\n```\n\n### Usage\n\nImplementing OAuthify in your React application involves three simple steps:\n\n1. Wrap your application with `\u003cOAuthifyProvider /\u003e`.\n2. Add the `\u003cOAuthifyRedirect /\u003e` component to handle the OAuth callback.\n3. Utilize the `\u003cGoogleLoginButton /\u003e` or `\u003cGithubLoginButton /\u003e` components as needed.\n\n### Detailed Steps\n\n#### OAuthifyProvider\n\nTo use the OAuthify Provider, wrap your entire application with `\u003cOAuthifyProvider\u003e`:\n\n```javascript\nimport React from 'react';\nimport {\n  OAuthifyProvider,\n  GoogleLoginButton,\n  GitHubLoginButton,\n  GoogleIcon,\n  GithubIcon,\n} from 'oauthify';\nimport { useOAuthify } from 'oauthify';\n\nconst googleClientId = 'xxxxxxxxx';\nconst githubClientId = 'XXXXXXXX';\n\nconst App = () =\u003e {\n  return (\n    \u003cOAuthifyProvider\u003e\n      \u003cdiv\u003e\n        \u003ch1\u003eMy App\u003c/h1\u003e\n        \u003cLoginComponent /\u003e\n      \u003c/div\u003e\n    \u003c/OAuthifyProvider\u003e\n  );\n};\n\nconst LoginComponent = () =\u003e {\n  const { onSuccess, onFailure, setOnSuccess } = useOAuthify();\n\n  const handleSuccess = () =\u003e {\n    // Handle the success state of LoginWithGoogle or LoginWithGithub\n  };\n  const handleFailure = () =\u003e {\n    // Handle the success state of LoginWithGoogle or LoginWithGithub\n  };\n\n  React.useEffect(() =\u003e {\n    handleSuccess();\n  }, [onSuccess]);\n\n  React.useEffect(() =\u003e {\n    handleFailure();\n  }, [onFailure]);\n  return (\n    \u003c\u003e\n      \u003cdiv className=\"flex flex-row justify-center items-center my-6 space-x-2\"\u003e\n        \u003cGoogleLoginButton clientId={googleClientId} redirectUri={redirectUri}\u003e\n          \u003cdiv\n            style={{\n              display: 'flex',\n              flexDirection: 'row',\n              alignItems: 'center',\n              justifyContent: 'center',\n              borderRadius: '4px',\n              border: '1px solid #e1e4e8',\n              padding: '6px 12px',\n              fontSize: '14px',\n            }}\n          \u003e\n            \u003cdiv className=\"mr-2\"\u003e\n              {' '}\n              \u003cGoogleIcon size={16} /\u003e{' '}\n            \u003c/div\u003e{' '}\n            {formType === 'signin' ? 'Sign in' : 'Sign up'} with Google\n          \u003c/div\u003e{' '}\n        \u003c/GoogleLoginButton\u003e\n\n        \u003cGitHubLoginButton clientId={githubClientId} redirectUri={redirectUri}\u003e\n          \u003e\n          \u003cdiv\n            style={{\n              display: 'flex',\n              flexDirection: 'row',\n              alignItems: 'center',\n              justifyContent: 'center',\n              borderRadius: '4px',\n              border: '1px solid #e1e4e8',\n              padding: '6px 12px',\n              fontSize: '14px',\n            }}\n          \u003e\n            \u003cdiv className=\"mr-2\"\u003e\n              {' '}\n              \u003cGithubIcon size={16} /\u003e\n            \u003c/div\u003e{' '}\n            {formType === 'signin' ? 'Sign in' : 'Sign up'} with GitHub\n          \u003c/div\u003e\n        \u003c/GitHubLoginButton\u003e\n      \u003c/div\u003e\n    \u003c/\u003e\n  );\n};\n\nexport default App;\n```\n\n#### NOTE: Please Ensure GoogleLoginButton and GithubLoginButton getting rendered under \u003cOAuthifyProvider/\u003e provider\n\n#### GoogleLoginButton\n\nTo use the Google login button:\n\n1. **Import and use the `GoogleLoginButton` component:**\n\n```javascript\nimport React from 'react';\nimport { GoogleLoginButton } from 'oauthify';\n\nconst App = () =\u003e {\n  // Use any of the ways to handle the success and failed state either the prop method or context hook\n  const handleSuccess = (response) =\u003e {\n    console.log('Google login success:', response);\n  };\n\n  const handleFailure = (error) =\u003e {\n    console.error('Google login failure:', error);\n  };\n\n  return (\n    \u003cdiv\u003e\n      \u003cGoogleLoginButton\n        clientId=\"YOUR_GOOGLE_CLIENT_ID\"\n        redirectUri={`${window.location.origin}/oauthify-redirect`}\n        onSuccess={handleSuccess}\n        onFailure={handleFailure}\n      \u003e\n        Login with Google\n      \u003c/GoogleLoginButton\u003e\n    \u003c/div\u003e\n  );\n};\n\nexport default App;\n```\n\n2. **Add a redirect page to handle the OAuth callback:**\n\nIn your router configuration file:\n\n```javascript\nimport { OAuthifyRedirect } from 'oauthify';\n\n{\n  path: '/oauthify-redirect',\n  component: OAuthifyRedirect\n}\n```\n\n#### GitHubLoginButton\n\nTo use the GitHub login button:\n\n1. **Import and use the `GitHubLoginButton` component:**\n\n```javascript\nimport React from 'react';\nimport { GitHubLoginButton } from 'oauthify';\n\nconst App = () =\u003e {\n  const handleSuccess = (response) =\u003e {\n    console.log('GitHub login success:', response);\n  };\n\n  const handleFailure = (error) =\u003e {\n    console.error('GitHub login failure:', error);\n  };\n\n  return (\n    \u003cdiv\u003e\n      \u003cGitHubLoginButton\n        clientId=\"YOUR_GITHUB_CLIENT_ID\"\n        redirectUri={`${window.location.origin}/oauthify-redirect`}\n        onSuccess={handleSuccess}\n        onFailure={handleFailure}\n      \u003e\n        Login with GitHub\n      \u003c/GitHubLoginButton\u003e\n    \u003c/div\u003e\n  );\n};\n\nexport default App;\n```\n\n2. **Reuse the same redirect page for handling OAuth callback as described for GoogleLoginButton.**\n\n### Contributions\n\nWe welcome and appreciate contributions! If you want to contribute, please follow these steps:\n\n1. Fork the repository on GitHub.\n2. Create a new branch (`git checkout -b feature/YourFeature`).\n3. Commit your changes (`git commit -am 'Add some feature'`).\n4. Push to the branch (`git push origin feature/YourFeature`).\n5. Open a Pull Request.\n\nWe encourage contributions for adding support for other providers, improving documentation, and fixing bugs. If you find this project helpful, please give it a star on GitHub to help others discover it!\n\n### Resources\n\n- **GitHub Repository:** [OAuthify on GitHub](https://github.com/shekhardtu/oauthify)\n- **Github Auth Library** [Github on NPM](https://www.npmjs.com/package/github-auth-library)\n- **NPM Package:** [OAuthify on NPM](https://www.npmjs.com/package/oauthify)\n- **Google OAuth Documentation:** [Google Identity Platform](https://developers.google.com/identity/protocols/oauth2)\n- **GitHub OAuth Documentation:** [GitHub OAuth Apps](https://docs.github.com/en/developers/apps/building-oauth-apps)\n\n### License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](https://github.com/shekhardtu/oauthify/blob/main/LICENSE.md) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshekhardtu%2Foauthify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshekhardtu%2Foauthify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshekhardtu%2Foauthify/lists"}