Comments (5)
Thank you for reporting the issue, I'll look into it!
I am also not user the accept header is correct. I am under the impression that is intended to be the GitHub App name.
You mean the accept: 'application/vnd.github.machine-man-preview+json'
header? That is currently required to be set for the POST/app/installations/access_tokens
endpoint. This is most likely a problem with https://github.com/octokit/auth-app.js/
from auth-app.js.
Ah that makes sense. Yes, I think @octokit/auth-app
is the better place to discuss this. I'll move the issue over there.
A GitHub App has two means of authentication
- As the app itself. Only a few endpoints accept this form of authentication. It is mostly used to create installation access tokens and to iterate through installations. The endpoints requiring authenticating as app are listed here: https://developer.github.com/v3/apps/
- As an installation. When you install an app on your GitHub user account or a GitHub organization, the GitHub app will be able to generation installation access tokens with the permissions requested by the app. They are similar to the OAuth/Personal access tokens. In order to create such an installation access token, you need to know the installation ID.
Often times you need an installation ID when you act upon a webhook request retrieved by GitHub. These webhook payloads include the installation ID in its payload.
If you want to manually find out the installation ID, open the APPs page and then installation configuration page. For example, install https://github.com/apps/wip/ on your account. The URL of that settings page will look like this: https://github.com/settings/installations/12345. 12345
is the installation ID. I assume it's the same with GitHub Enterprise Server.
You are not the first who is confused by this, I'm very open to suggestions on how to improve the library (e.g. better error messages) and/or how to improve the documentation.
I was looking into automatically setting setting the correct authentication type automatically, by deriving the correct strategy form the API endpoint. E.g. octokit.repos.getContents
sends a request to GET /repos/:owner/:repo/contents/:path
. Based on that, I know the correct authentication strategy is an installation token, and I can derive that from :owner
. Unfortunately not all endpoints use the owner prefix yet, so this would work for some methods, but not all, probably causing even more confusion. So I'm holding off until GitHub added new endpoints replacing the old ones such as "Update a project", which currently is PATCH /projects/:project_id
, but it really should be PATCH /repos/:owner/:repo/projects/:project_id
.
Sorry, that was probably more information than you asked for :) I hope I could convey the difference between app & installation authentication and why it's ... complicated
from auth-app.js.
closing due to inactivity. As a reminder, you need to set installationId
on auth: { appId, privateKey, installationId }
in order to utilize repository APIs
from auth-app.js.
Where does Octokit
come from in your code example? The octokit.repos.getContents
method implies you load rest endpoint methods, but you seem to only load the admin methods via enterpriseServer219Admin?
Is Octokit
imported from @octokit/rest
or @octokit/core
? What version? Can you run npm ls | grep octokit
and paste the output here?
from auth-app.js.
Rest. I updated the example.
The issue was that I was missing the installationId
in the Auth Object. However, I could not find any docs about what this is or how to obtain installationId
. I used the App ID for this field and that seems to work. Would a ticket on @octokit/auth-app
better suit the situation?
from auth-app.js.
Related Issues (20)
- [BUG]: ReferenceError: Property 'atob' doesn't exist HOT 9
- [BUG]: secretOrPrivateKey must be an asymmetric key when using RS256 HOT 29
- [BUG]: package files not published to npm HOT 1
- [BUG]: unable to use this package with `@actions/github-script` HOT 19
- [DOCS]: Node version requirements HOT 3
- Replace `toMatchObject` Response assertions with `toEqual` in `auth-app.js` HOT 1
- [DOCS]: Implementation of GitHub App user authentication token with expiring disabled HOT 6
- [BUG]: Cache#get type doesn't allow promises HOT 2
- [BUG]: Upgrade universal-github-app-jwt 1.1.2 to close CVE-2022-25883 HOT 5
- Default flow results in error for missing installationId HOT 5
- [BUG]: `octokit.request("PATCH /app/hook/config", { url })` throws error `installationId option is required for installation authentication` HOT 1
- [BUG]: Handle 403 responses same as 401 responses in the first 3 seconds after an installation access token was created HOT 1
- [BUG]: /app/installation-requests missing from PATHS in requires-app-auth HOT 3
- Revisit skipped tests HOT 1
- `appId` can now be set to the application's Client ID HOT 2
- [MAINT]: use stable `semantic-release` HOT 2
- [BUG]: require("@octokit/auth-app"); Error [ERR_REQUIRE_ESM]: require() of ES Module HOT 6
- [BUG]: Update 6.1.0 -> 6.1.1 results in runtime error in AWS HOT 6
- Document that clientId may be assigned to the appId property HOT 1
- [BUG]: when setting `baseUrl` as part of parameters, the `baseUrl` is not passed through to `getInstallationAuthentication` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from auth-app.js.