{"id":15454496,"url":"https://github.com/gr2m/register-github-app","last_synced_at":"2025-04-21T09:04:18.967Z","repository":{"id":232292102,"uuid":"783959268","full_name":"gr2m/register-github-app","owner":"gr2m","description":"Register a GitHub App using the manifest flow","archived":false,"fork":false,"pushed_at":"2024-04-26T12:15:03.000Z","size":80,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-20T00:54:11.683Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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":null,"license":"license","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},"funding":{"github":"gr2m"}},"created_at":"2024-04-08T23:06:03.000Z","updated_at":"2025-03-30T00:52:17.000Z","dependencies_parsed_at":"2024-08-11T08:23:12.898Z","dependency_job_id":"728ff1f9-3054-4ffc-806e-80abc9181569","html_url":"https://github.com/gr2m/register-github-app","commit_stats":{"total_commits":17,"total_committers":1,"mean_commits":17.0,"dds":0.0,"last_synced_commit":"5d81e98a34aaa0f292db1db405b7c57811031dac"},"previous_names":["gr2m/register-github-app"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Fregister-github-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Fregister-github-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Fregister-github-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Fregister-github-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gr2m","download_url":"https://codeload.github.com/gr2m/register-github-app/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249834786,"owners_count":21331988,"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-01T22:03:27.698Z","updated_at":"2025-04-20T00:54:15.773Z","avatar_url":"https://github.com/gr2m.png","language":"JavaScript","funding_links":["https://github.com/sponsors/gr2m"],"categories":[],"sub_categories":[],"readme":"# `register-github-app`\n\n\u003e Register a GitHub App using the manifest flow\n\n## Usage\n\nhttps://github.com/gr2m/register-github-app/assets/39992/61cbc419-df95-4043-b18b-7ead07f56e3b\n\n### Minimal\n\n```js\nimport registerGitHubApp from \"register-github-app\";\nconst appCredentials = await registerGitHubApp();\nconsole.log(appCredentials);\n```\n\n### Write credentials into a `.env` file.\n\n```js\nimport fs from \"node:fs/promises\";\nimport crypto from \"node:crypto\";\n\nimport registerGitHubApp from \"register-github-app\";\n\n// register app and retrieve credentials\nconst appCredentials = await registerGitHubApp({\n  // name of your app\n  name: \"my-github-app\",\n  // Homepage of your app, e.g. your app's repository or your org/user account\n  url: \"https://github.com/monatheoctocat/monas-github-app\",\n  // object of permissions for new installations\n  default_permissions: {\n    issues: \"write\",\n  },\n  // List of events for new installations\n  evedefault_events: [\"issues\"],\n});\n\n// convert private key to pkcs8 format (recommended for better cross plattform support)\nconst privateKeyPKCS8 = String(\n  crypto.createPrivateKey(appCredentials.pem).export({\n    type: \"pkcs8\",\n    format: \"pem\",\n  }),\n);\nconst singleLinePrivateKey = privateKeyPKCS8.trim().replace(/\\n/g, \"\\\\n\");\n\n// write credentials into `.env` file\nawait fs.writeFile(\n  \".env\",\n  `GITHUB_APP_ID=${appCredentials.id}\nGITHUB_APP_PRIVATE_KEY=\"${singleLinePrivateKey}\"\nGITHUB_APP_WEBHOOK_SECRET=${appCredentials.webhook_secret}\nGITHUB_APP_CLIENT_ID=${appCredentials.client_id}\nGITHUB_APP_SECRET=${appCredentials.client_secret}\n`,\n);\n```\n\n### Register an app on an organization\n\n```js\nimport registerGitHubApp from \"register-github-app\";\n\n// register app and retrieve credentials\nconst appCredentials = await registerGitHubApp({\n  org: \"my-organization-login\",\n  // name of your app\n  name: \"my-github-app\",\n  // object of permissions for new installations\n  default_permissions: {\n    issues: \"write\",\n  },\n  // List of events for new installations\n  evedefault_events: [\"issues\"],\n});\n```\n\n## See also\n\n- https://github.com/gr2m/register-github - CLI to register a GitHub API using the manifest flow\n\n## How it works\n\nRegistering a GitHub App using the manifest flow is an alternative to manually register a GitHub App on a user account or an organization. Here is what the `register-github-app` does\n\n1. Starts a server on a random available port.\n2. When opened in browser, it generates an HTML form with an input named `manifest` which value is set to a JSON string with the app manifest settings, and submits the form to github.com\n3. On github.com, the user will be prompted to sign in or enter [sudo mode](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/sudo-mode).\n4. Once authenticated, the user has to confirm the GitHub App name. It must be globally unique.\n5. Once confirmed, the browser redirects to server started in the first step with a one-time code\n6. The app credentials are retrieved using the one-time code, the server is stopped, and the credentials are returned\n\n## Resources\n\n- [Registering a GitHub App from a manifest](https://docs.github.com/en/apps/sharing-github-apps/registering-a-github-app-from-a-manifest)\n\n## License\n\n[ISC](license)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgr2m%2Fregister-github-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgr2m%2Fregister-github-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgr2m%2Fregister-github-app/lists"}