{"id":29010980,"url":"https://github.com/shekhardtu/github-auth-library","last_synced_at":"2026-04-25T08:36:47.087Z","repository":{"id":243507316,"uuid":"812607088","full_name":"shekhardtu/github-auth-library","owner":"shekhardtu","description":"The github-auth-library is a Node.js library designed to handle OAuth authentication with GitHub. It provides a simple interface to authenticate users, retrieve access tokens, and fetch user details using GitHub's API. This library is designed to follow the SOLID principles, making it extensible and maintainable.","archived":false,"fork":false,"pushed_at":"2024-06-16T16:50:28.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-01T16:00:44.003Z","etag":null,"topics":["github","github-api","github-auth-libarary","github-node-sdk","github-oauth2","github-sdk"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/github-auth-library","language":"JavaScript","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,"zenodo":null}},"created_at":"2024-06-09T11:25:35.000Z","updated_at":"2024-06-16T16:50:31.000Z","dependencies_parsed_at":"2025-06-25T17:10:31.260Z","dependency_job_id":"8f8fdf9e-3f2a-4456-9022-457f9bde0c12","html_url":"https://github.com/shekhardtu/github-auth-library","commit_stats":null,"previous_names":["shekhardtu/github-auth-library"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shekhardtu/github-auth-library","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shekhardtu%2Fgithub-auth-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shekhardtu%2Fgithub-auth-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shekhardtu%2Fgithub-auth-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shekhardtu%2Fgithub-auth-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shekhardtu","download_url":"https://codeload.github.com/shekhardtu/github-auth-library/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shekhardtu%2Fgithub-auth-library/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32255810,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T04:23:17.126Z","status":"ssl_error","status_checked_at":"2026-04-25T04:21:53.360Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","github-api","github-auth-libarary","github-node-sdk","github-oauth2","github-sdk"],"created_at":"2025-06-25T17:10:24.233Z","updated_at":"2026-04-25T08:36:47.072Z","avatar_url":"https://github.com/shekhardtu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GitHub Auth Library\n\nThe `github-auth-library` is a Node.js library designed to handle OAuth authentication with GitHub. It provides a simple interface to authenticate users, retrieve access tokens, and fetch user details using GitHub's API. This library is designed to follow the SOLID principles, making it extensible and maintainable.\n\n## Features\n\n- Easy-to-use methods for GitHub OAuth authentication.\n- Methods to exchange authorization code for access token.\n- Methods to fetch user details using the access token.\n- Structured to follow SOLID principles for better maintainability and extensibility.\n- Ready for integration into your Node.js application.\n\n## Installation\n\n```bash\nnpm install github-auth-library\n```\n\n## Usage\n\n### Initialize the GitHub SDK\n\nTo use the library, you need to initialize the `GitHubSDK` with your GitHub OAuth application's client ID and client secret.\n\n```javascript\nconst GitHubSDK = require(\"github-auth-library\");\n\nconst githubSDK = new GitHubSDK(\n  \"YOUR_GITHUB_CLIENT_ID\",\n  \"YOUR_GITHUB_CLIENT_SECRET\"\n);\n```\n\n### Exchange Authorization Code for Access Token\n\nYou can exchange the authorization code received from GitHub for an access token using the `getToken` method.\n\n```javascript\nconst code = \"AUTHORIZATION_CODE_RECEIVED_FROM_GITHUB\";\nconst redirectUri = \"YOUR_REDIRECT_URI\";\n\ngithubSDK\n  .getToken(code, redirectUri)\n  .then((token) =\u003e {\n    console.log(\"Access Token:\", token);\n  })\n  .catch((error) =\u003e {\n    console.error(\"Error getting access token:\", error);\n  });\n```\n\n### Fetch User Details\n\nOnce you have the access token, you can fetch the user details using the `getUserInfo` method.\n\n```javascript\nconst token = {\n  access_token: \"YOUR_ACCESS_TOKEN\",\n};\n\ngithubSDK\n  .getUserInfo(token)\n  .then((userInfo) =\u003e {\n    console.log(\"User Info:\", userInfo);\n  })\n  .catch((error) =\u003e {\n    console.error(\"Error getting user info:\", error);\n  });\n```\n\n## Methods\n\n### `getToken(code, redirectUri)`\n\n- **Description**: Exchanges the authorization code for an access token.\n- **Parameters**:\n  - `code` (string): The authorization code received from GitHub.\n  - `redirectUri` (string): The redirect URI registered with your GitHub OAuth application.\n- **Returns**: A promise that resolves to the access token.\n- **Reference**: [GitHub OAuth Documentation](https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps)\n\n### `getUserInfo(token)`\n\n- **Description**: Fetches user details using the access token.\n- **Parameters**:\n  - `token` (object): An object containing the access token (`access_token`).\n- **Returns**: A promise that resolves to the user details.\n- **Reference**: [GitHub Users API Documentation](https://docs.github.com/en/rest/reference/users#get-the-authenticated-user)\n\n## Example\n\nHere is an example of using the `github-auth-library` in an Express.js application to handle GitHub OAuth authentication.\n\n```javascript\nconst express = require(\"express\");\nconst GitHubSDK = require(\"github-auth-library\");\nconst app = express();\n\nconst githubSDK = new GitHubSDK(\n  \"YOUR_GITHUB_CLIENT_ID\",\n  \"YOUR_GITHUB_CLIENT_SECRET\"\n);\n\napp.post(\"/github-auth\", async (req, res) =\u003e {\n  const { code, redirectUri } = req.body;\n\n  try {\n    const token = await githubSDK.getToken(code, redirectUri);\n    const userInfo = await githubSDK.getUserInfo(token);\n    res.status(200).json({ user: userInfo, token });\n  } catch (error) {\n    res.status(401).json({ message: \"Unauthorized\", error });\n  }\n});\n\nconst PORT = process.env.PORT || 3000;\napp.listen(PORT, () =\u003e {\n  console.log(`Server is running on port ${PORT}`);\n});\n```\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\n### Resources\n\n- **Github Auth Library** [Github-Auth-Library on NPM](https://www.npmjs.com/package/github-auth-library)\n- **Github Auth Library** [Github-Auth-Library on Github](https://github.com/shekhardtu/github-auth-library)\n- **GitHub Repository:** [OAuthify on GitHub](https://github.com/shekhardtu/oauthify)\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshekhardtu%2Fgithub-auth-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshekhardtu%2Fgithub-auth-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshekhardtu%2Fgithub-auth-library/lists"}