{"meta":{"title":"Authenticating as a GitHub App","intro":"You can authenticate as a GitHub App in order to generate an installation access token or manage your app.","product":"Apps","breadcrumbs":[{"href":"/en/apps","title":"Apps"},{"href":"/en/apps/creating-github-apps","title":"Creating GitHub Apps"},{"href":"/en/apps/creating-github-apps/authenticating-with-a-github-app","title":"Authenticate with a GitHub App"},{"href":"/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app","title":"Authenticate as an app"}],"documentType":"article"},"body":"# Authenticating as a GitHub App\n\nYou can authenticate as a GitHub App in order to generate an installation access token or manage your app.\n\n## About authentication as a GitHub App\n\nYou must authenticate as a GitHub App in order to make REST API requests as the application. For example, if you want to use the API to generate an installation access token for accessing organization resources, list installations across accounts for your app, or suspend an app installation, you must authenticate as an app.\n\nIf a REST API endpoint requires you to authenticate as an app, the documentation for that endpoint will indicate that you must use a JWT to access the endpoint. The GraphQL API does not support any queries or mutations that require you to authenticate with a JWT.\n\n## Using a JSON Web Token (JWT) to authenticate as a GitHub App\n\n1. Generate a JSON Web Token (JWT) for your app. For more information, see [Generating a JSON Web Token (JWT) for a GitHub App](/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-json-web-token-jwt-for-a-github-app).\n2. Include the JWT in the `Authorization` header of your request. In the following example, replace `YOUR_JWT` with your JWT.\n\n   ```shell\n   curl --request GET \\\n   --url \"https://api.github.com/app/installations\" \\\n   --header \"Accept: application/vnd.github+json\" \\\n   --header \"Authorization: Bearer YOUR_JWT\" \\\n   --header \"X-GitHub-Api-Version: 2026-03-10\"\n   ```\n\n## Using the Octokit.js SDK to authenticate as a GitHub App\n\nYou can use GitHub's Octokit.js SDK to authenticate as a GitHub App. One advantage of using the SDK to authenticate is that you do not need to generate a JSON web token (JWT) yourself. Additionally, the SDK will take care of regenerating the JWT when it expires.\n\n> \\[!NOTE]\n> You must install and import `octokit` in order to use the Octokit.js library. The following example uses import statements in accordance with ES6. For more information about different installation and import methods, see [Usage](https://github.com/octokit/octokit.js/#usage) in the octokit/octokit repository.\n\n1. Get the ID of your app. You can find your app's ID on the settings page for your GitHub App. For more information about navigating to the settings page for your GitHub App, see [Modifying a GitHub App registration](/en/apps/maintaining-github-apps/modifying-a-github-app-registration#navigating-to-your-github-app-settings).\n\n2. Generate a private key. For more information, see [Managing private keys for GitHub Apps](/en/apps/creating-github-apps/authenticating-with-a-github-app/managing-private-keys-for-github-apps).\n\n3. Import `App` from `octokit`.\n\n   ```javascript copy\n   import { App } from \"octokit\";\n   ```\n\n4. Create a new instance of `App`. In the following example, replace `APP_ID` with a reference to your app's ID. Replace `PRIVATE_KEY` with a reference to the value of your app's private key.\n\n   ```javascript copy\n    const app = new App({\n     appId: APP_ID,\n     privateKey: PRIVATE_KEY,\n   });\n   ```\n\n5. Use an `octokit` method to make a request to a REST API endpoint that requires a JWT. For example:\n\n   ```javascript copy\n   await app.octokit.request(\"/app\")\n   ```"}