Comments (6)
The 404 error is see is not coming from the GET /app/orgs/:org/projects
request, but from POST https://api.github.com/app/installations//access_tokens
. The createAppAuth
strategy is sending the request to retrieve an installation token automatically for you, you don't need to do that manually.
What you need to do though is to set the auth.installationId
option.
Try this
new Octokit({
authStrategy: createAppAuth,
auth: {
id: process.env.GITHUB_APP_ID,
privateKey: pemKey,
installationid
},
userAgent: "blabla",
previews: ["inertia"],
});
await session.request("GET /app/orgs/:org/projects", {
headers: {
authorization: `token ${installToken}`,
},
org,
});
from request.js.
Thanks a lot for the fast help and this whole framework. That way, it works. Surprisingly (I was looking at that), this is not working though:
const sessionMaker = Octokit.defaults({
authStrategy: createAppAuth,
auth: {
id: process.env.GITHUB_APP_ID,
privateKey: pemKey,
},
userAgent: 'blabla',
baseUrl: 'https://api.github.com',
previews: ['inertia', 'machine-man'],
});
followed by
const session = new sessionMaker(options =>
({
...options,
auth: {
...options.auth,
installationId,
permissions: {
organization_projects: 'write',
}
},
})
);
from request.js.
you are passing a function to sessionMaker
, try passing the options object instead
const session = new sessionMaker({
...options,
auth: {
...options.auth,
installationId,
permissions: {
organization_projects: "write",
},
},
});
from request.js.
Yes, thank you, you are right of course. But do not you think that defeats the purpose of the default options? I mean I have defined a defaultOptions object that I specialize when calling a specific new Octokit(). But certainly not a big deal anyway...
from request.js.
You can create a constructor which has the app auth strategy and app ID + private key configured
const OctokitWithAppAuth = Octokit.defaults({
authStrategy: createAppAuth,
auth: {
id: process.env.GITHUB_APP_ID,
privateKey: pemKey,
},
});
Then use that custom constructor to initiate instances for an installation
const octokit = new OctokitWithAppAuth({
auth: {
installationId
},
});
from request.js.
Neat and nice. Thank you Gregor.
from request.js.
Related Issues (20)
- [BUG]: Started facing Could not find a declaration file for module '@octokit/request' from yesterday Onwards HOT 2
- [BUG]: octokit function is due to `repos/.../pulls` internal server error HOT 4
- [BUG]: Breaking change released under a patch version HOT 1
- [FEAT]: Allow streaming of the data HOT 14
- [MAINT]: Upgrade `@octokit/endpoint`
- [BUG]: `redirect` option not passed through HOT 3
- Document on how to use the new fetch API equivalent to http agents HOT 6
- Update error message in `request.js` HOT 1
- [BUG]: Redirect option is not passed through... HOT 5
- [BUG]: Network errors from unidici are not properly surfaced HOT 2
- [BUG]: Undici network errors still not surfaced properly HOT 2
- [BUG]: Unexpected end of JSON input HOT 2
- [BUG]: HttpError: Unexpected end of JSON input when utilizing `if-none-match` header HOT 1
- [BUG]: With parseSuccessResponseBody set to false, the return type is improperly set HOT 4
- [FEAT]: Include `documentation_url` in `HttpError` output HOT 3
- [BUG]: Workflows fail on forks HOT 1
- [BUG]: Typos in repository HOT 3
- [BUG]: `release.yml` needs `contents: write` HOT 3
- [BUG]: prettier doesn't work on forks HOT 1
- The automated release is failing 🚨
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 request.js.