{"id":15479862,"url":"https://github.com/gr2m/cloudflare-worker-github-oauth-login","last_synced_at":"2025-04-19T23:49:19.679Z","repository":{"id":48174241,"uuid":"205192828","full_name":"gr2m/cloudflare-worker-github-oauth-login","owner":"gr2m","description":"Use a Cloudflare worker for GitHub's OAuth login flow","archived":false,"fork":false,"pushed_at":"2023-07-12T23:46:40.000Z","size":30,"stargazers_count":158,"open_issues_count":2,"forks_count":48,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-10T10:42:03.181Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://gr2m.github.io/cloudflare-worker-github-oauth-login/index.html","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gr2m.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":"gr2m"}},"created_at":"2019-08-29T15:23:18.000Z","updated_at":"2025-02-13T05:58:35.000Z","dependencies_parsed_at":"2022-08-28T08:04:01.822Z","dependency_job_id":"c2294f8a-3f63-4323-9ee5-809da7e23759","html_url":"https://github.com/gr2m/cloudflare-worker-github-oauth-login","commit_stats":{"total_commits":42,"total_committers":5,"mean_commits":8.4,"dds":"0.38095238095238093","last_synced_commit":"6f9e8a523f7a1f804545eaa2e64e25cb3751c4a1"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Fcloudflare-worker-github-oauth-login","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Fcloudflare-worker-github-oauth-login/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Fcloudflare-worker-github-oauth-login/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Fcloudflare-worker-github-oauth-login/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gr2m","download_url":"https://codeload.github.com/gr2m/cloudflare-worker-github-oauth-login/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249617511,"owners_count":21300693,"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":[],"created_at":"2024-10-02T04:28:23.610Z","updated_at":"2025-04-19T23:49:19.660Z","avatar_url":"https://github.com/gr2m.png","language":"HTML","funding_links":["https://github.com/sponsors/gr2m"],"categories":["HTML"],"sub_categories":[],"readme":"# cloudflare-worker-github-oauth-login\n\n\u003e A Cloudflare Worker + GitHub Pages Login Example\n\nThe [github-oauth-login.js](github-oauth-login.js) file is a [Cloudflare Worker](https://workers.cloudflare.com/) which is continuously deployed using GitHub Actions (see [.github/workflows/deploy.yml](.github/workflows/deploy.yml)).\n\nThe worker does 3 things\n\n1. When you open the worker URL, it will redirect to the OAuth App's login URL on github.com ([example](https://github-oauth-login.gr2m.workers.dev)).\n2. It accepts a `POST` request with the OAuth `code` retrieved from the OAuth callback redirect and returns an OAuth access token in return\n3. It enables CORS.\n\nThe [index.html](index.html) file is a demo of a \"Login with GitHub\" app, you can see the demo at [gr2m.github.io/cloudflare-worker-github-oauth-login/index.html](https://gr2m.github.io/cloudflare-worker-github-oauth-login/index.html). Look at its source code. If something is unclear, please feel free to [open an issue](https://github.com/gr2m/cloudflare-worker-github-oauth-login/issues) or [ping me on twitter](https://twitter.com/gr2m).\n\n## Step-by-step instructions to create your own\n\nNote that you require access to the new GitHub Actions for the automated deployment to work.\n\n1. [Create a GitHub App](https://developer.github.com/apps/building-github-apps/creating-a-github-app/) or [GitHub OAuth App](https://developer.github.com/apps/building-oauth-apps/creating-an-oauth-app/)\n1. Fork this repository\n1. [Create a Cloudflare account](https://dash.cloudflare.com/) (it's free!) if you don't have one yet.\n1. Install the `wrangler` CLI and login with your account\n\n   ```\n   npm install --global wrangler\n   wrangler login\n   ```\n\n1. Edit the `wrangler.toml` file, change the value for `account_id` to your own ([select your account](https://dash.cloudflare.com/), then find your Account ID at the bottom of the side bar)\n1. Add the following secrets to your Cloudflare worker:\n\n   - `CLIENT_ID`, `CLIENT_SECRET`: In your GitHub (OAuth) App's settings page, find `Client ID` and `Client SECRET`\n\n     ```\n     wrangler secret put CLIENT_ID\n     wrangler secret put CLIENT_SECRET\n     ```\n\n1. Add the following secret in your fork's repository settings:\n   - `CF_API_TOKEN`: [Create a new token](https://dash.cloudflare.com/profile/api-tokens), use the \"Edit Cloudflare Workers\" template\n1. Enable GitHub Pages in your repository settings, select `Source` to be the `master branch`.\n1. In [index.html](index.html), replace the `gr2m` workers subdomain with your own, in `WORKER_URL` and the login `\u003ca href=\"...\"\u003e` tag.\n\nThat should be it. The `github-oauth-login.js` file will now be continously deployed to Cloudflare each time there is a commit to master.\n\n## See also\n\n- [Cloudflare Worker GitHub App Example](https://github.com/gr2m/cloudflare-worker-github-app-example/#readme)\n\n## Credits\n\nThe OAuth App Avatar and this repository's social preview are using [@cameronmcefee](https://github.com/cameronmcefee)'s [cloud](https://octodex.github.com/cloud/) Octodex graphic :octocat:💖\n\n## License\n\n[ISC](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgr2m%2Fcloudflare-worker-github-oauth-login","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgr2m%2Fcloudflare-worker-github-oauth-login","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgr2m%2Fcloudflare-worker-github-oauth-login/lists"}