[Typescript] Octokit "auth" option does not support example from docs for installation tokens
See original GitHub issueI recently updated the following octokit modules and began receiving a deprecation warning about not providing an authStrategy
.
Deprecation Warning
Setting the “new Octokit({ auth })” option to an object without also setting the “authStrategy” option is deprecated and will be removed in v17. See (https://octokit.github.io/rest.js/#authentication)
Octokit Modules
"@octokit/app": "4.1.1",
"@octokit/auth-app": "2.4.2",
"@octokit/plugin-retry": "3.0.1",
"@octokit/plugin-throttling": "3.2.0",
"@octokit/rest": "16.40.1",
"@octokit/webhooks": "7.0.0",
Code That Raises Deprecation Warning
import OctokitRest from '@octokit/rest';
const client = new OctokitRest({
async auth(): Promise<string> {
const token = await app.getInstallationAccessToken({
installationId: MY_INSTALLATION_ID,
});
return `token ${token}`;
},
...
});
Code I Would Like To Use
import { createAppAuth } from '@octokit/auth-app';
import OctokitRest from '@octokit/rest';
const client = new OctokitRest({
authStrategy: createAppAuth,
auth: {
id: MY_APP_ID,
privateKey: MY_PRIVATE_KEY,
installationId: MY_INSTALLATION_ID
},
...
});
Discrepancy to Documentation
Per the example in the documentation, I should be able to specify the app id
and privateKey
as the auth
settings but those are not valid per the current typescript definition.
Proposal
Not sure if this is on your roadmap to v17, but if not then here’s my two cents.
Since the octokit rest module’s authentication plugin just passes options.auth
to the auth strategy via const auth = options.authStrategy(options.auth);
, should the typescript definition for auth
in this octokit rest module match StrategyOptions type as shown in the auth-app usages?
Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:13 (10 by maintainers)
Or you could make a sort of strategy registry;
which can then be augmented by consumers/strategy authors with
I see, thank you! Didn’t think about that possibility!