我希望我的GitHub应用程序代表用户执行操作,比如创建问题。
我以这种方式验证我的用户:
const { createOAuthAppAuth } = require('@octokit/auth-oauth-app');
const auth = createOAuthAppAuth({
clientType: 'oauth-app',
clientId: clientGithubID,
clientSecret: clientSecretGithub,
});
const userAuthenticationFromWebFlow = await auth({
type: 'oauth-user',
code,
state: userId,
});
// console.log(useAuthenticationFromWebFlow)
// {
// "type": "token",
// "tokenType": "oauth",
// "clientType": "oauth-app",
// "clientId": "Iv1.CLIENTID",
// "clientSecret": "CLIENTSECRET",
// "token": "ghu_bunchofchars",
// "scopes": []
// }看起来我得到的令牌是好的。
现在的问题是,当我稍后尝试在我的代码中创建Octokit时,这不起作用
octokit = new Octokit({
authStrategy: userAuthenticationFromWebFlow,
});await octokit.issues.createComment({...props})创建Octokit实例的正确方式是什么?
谢谢!
发布于 2021-09-10 15:55:11
所以我找到了答案,
也许这能帮助到某些人。
const { createOAuthAppAuth } = require('@octokit/auth-oauth-app');
octokit = new Octokit({
authStrategy: createOAuthAppAuth,
auth: userAuthenticationFromWebFlow.token,
});而且它起作用了!
https://stackoverflow.com/questions/69134485
复制相似问题