auth-app.js: Throw a descriptive error when permissions is not set
Hello,
I ran into an issue where when I did not set a permissions object, even an empty one, in the the auth options I would see the following error:
Cannot convert undefined or null to object
Upon debugging it seems as if it comes from here:
If no permissions are passed in, the Object.keys throws the Cannot convert undefined or null object.
It was not clear from the documentation that the permissions object is required. Examples in the documentation seem to leave that out.
Small Reproducer
const auth = createAppAuth({
id: 123,
privateKey: `-----BEGIN RSA PRIVATE KEY-----...`,
installationId: 456,
});
const installationAuthentication = await auth({
type: 'installation',
// permissions: {}, // This is what I added to make it work
});
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (7 by maintainers)
Commits related to this issue
- docs(README): add not about `permissions` option for `auth()` / GHES 2.18 addresses #47 — committed to octokit/auth-app.js by gr2m 4 years ago
- docs(README): add not about `permissions` option for `auth()` / GHES 2.18 addresses #47 — committed to octokit/auth-app.js by gr2m 4 years ago
FWIW, I am also on Enterprise 2.18 and had to add the empty permissions object in order to get the request to work successfully.
From my testing, the permissions are all the permissions inherited from the installation.
I’d phrase it as
@gr2m My enterprise version is now 2.20.0 and I can generate a token without the empty permissions object now.
We are upgrading at the end of this month, so I can try again at the start of March and let you know.