{"id":13394510,"url":"https://github.com/mxstbr/micro-github","last_synced_at":"2025-04-04T17:10:00.577Z","repository":{"id":83297899,"uuid":"80948788","full_name":"mxstbr/micro-github","owner":"mxstbr","description":"A tiny microservice that makes adding authentication with GitHub to your application easy.","archived":false,"fork":false,"pushed_at":"2019-10-11T08:25:27.000Z","size":22,"stargazers_count":726,"open_issues_count":4,"forks_count":42,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-02T19:53:23.613Z","etag":null,"topics":["github","github-api","micro","microservices","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mxstbr.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-02-04T21:11:11.000Z","updated_at":"2025-03-18T11:07:05.000Z","dependencies_parsed_at":"2023-03-12T17:54:40.285Z","dependency_job_id":null,"html_url":"https://github.com/mxstbr/micro-github","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxstbr%2Fmicro-github","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxstbr%2Fmicro-github/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxstbr%2Fmicro-github/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxstbr%2Fmicro-github/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mxstbr","download_url":"https://codeload.github.com/mxstbr/micro-github/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247217222,"owners_count":20903009,"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","github-api","micro","microservices","nodejs"],"created_at":"2024-07-30T17:01:22.091Z","updated_at":"2025-04-04T17:10:00.562Z","avatar_url":"https://github.com/mxstbr.png","language":"JavaScript","readme":"# `micro-github`\n\nA tiny microservice that makes adding authentication with GitHub to your application easy.\n\n## Usage\n\nRunning your own `micro-github` is a single [`now`](https://now.sh) command away:\n\n```sh\n# Deploy this repository using now.sh\nnow mxstbr/micro-github -e GH_CLIENT_ID=xyz123 -e GH_CLIENT_SECRET=asdf123 -e REDIRECT_URL=https://google.com\n```\n\n### Environment variables\n\nYou'll need to provide three environment variables when running `micro-github`:\n\n```sh\n# Your GitHub application client id\nGH_CLIENT_ID=xyz123\n# Your GitHub application client secret\nGH_CLIENT_SECRET=asdf123\n# The URL to redirect the user to once the authentication was successful\nREDIRECT_URL=https://google.com\n# Optional: Specify the GitHub host when using GitHub Enterprise\nGH_HOST=github.my-company.com\n```\n\n\u003e Create an application on GitHub [here](https://github.com/settings/applications/new) to get your client id and secret if you haven't done that already.\n\nWhen authentication is successful, the user will be redirected to the `REDIRECT_URL` with the `access_token` query param set to the GitHub access token. You can then use that token to interact with the [GitHub API](https://developer.github.com/v3/)!\n\n\u003e E.g. setting `REDIRECT_URL=https://google.com` will redirect them to `https://google.com/?access_token=asdf123`. (where `asdf123` is the provided access token)\n\n### Finish setup\n\nTo make this work you have to set the authorization callback URL of [your application on GitHub](https://github.com/settings/developers) to whatever URL `now` gave you plus the path `/callback` e.g. `http://localhost:3000/callback`:\n\n![Authorization callback URL: 'your-url.now.sh'](https://cloud.githubusercontent.com/assets/168870/24585953/9543e03a-178e-11e7-8f10-07be5c10682c.png)\n\nTo log people in provide a link to url `now` gave you plus the path `login` e.g. `http://localhost:3000/login` when they click on the link it will redirect to `https://github.com/login/oauth/authorize?client_id=asdf123\u0026state`. (where `client_id` is your GitHub app client id in `.env` and `state` is a randomly generated string). This will redirect them to the GitHub sign in page for your app, which looks like this:\n\n![Authorize my app to access your data on GitHub](https://cloud.githubusercontent.com/assets/7525670/22627265/fc50c680-ebbf-11e6-9126-dcdef37d3c3d.png)\n\n\u003e You can change the scope of the data you can access with the `scope` query param, see the [GitHub docs](https://developer.github.com/v3/oauth/#scopes)!\n\nWhen authentication is successful, the user will be redirected to the `REDIRECT_URL` with the access token from GitHub for you to use! 🎉\n\n### Error handling\n\nIn case an error happens (either by the service or on GitHub) the user will be redirected to the `REDIRECT_URL` with the `error` query param set to a relevant error message.\n\n## Development\n\n```sh\ngit clone git@github.com:mxstbr/micro-github.git\n```\n\nMove `.env.example` to `.env` and fill in your GitHub API details and redirect url\n\n```sh\nnpm run dev\n```\n\nThe server will then be listening at `localhost:3000`, so set the authorization callback URL of your dev application on GitHub to `http://localhost:3000/callback`.\n\n## Updating\n\nThe `master` branch of this repository is what you will be deploying. To update to a new version with potential bugfixes, all you have to do is run the `now` command again and then set the authorization callback URL on GitHub to the new URL that `now` gave you! 👌\n\n## License\n\nCopyright (c) 2017 Maximilian Stoiber, licensed under the MIT license. See [LICENSE.md](LICENSE.md) for more information.\n","funding_links":[],"categories":["JavaScript","Built with Micro"],"sub_categories":["Utilities"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmxstbr%2Fmicro-github","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmxstbr%2Fmicro-github","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmxstbr%2Fmicro-github/lists"}