octokit rest节点js:授权用户名和密码获取;传递给createTokenAuth的令牌不是字符串;错误 编辑:尽管我试图让它工作5个多小时,但我只是看到我下面描述的方法实际上是不推荐的。任何落入我陷阱的人都应该使用访问令牌()然后()
当使用带有node js的octokit rest包对github用户进行身份验证时,指南似乎非常简单octokit rest节点js:授权用户名和密码获取;传递给createTokenAuth的令牌不是字符串;错误 编辑:尽管我试图让它工作5个多小时,但我只是看到我下面描述的方法实际上是不推荐的。任何落入我陷阱的人都应该使用访问令牌()然后(),rest,npm,octokit,Rest,Npm,Octokit,当使用带有node js的octokit rest包对github用户进行身份验证时,指南似乎非常简单 const { Octokit } = require('@octokit/rest'); const octokit = new Octokit({ auth: { username: this_username, password: this_password, on2fa () { return prompt('Enter code') } } }
const { Octokit } = require('@octokit/rest');
const octokit = new Octokit({
auth: {
username: this_username,
password: this_password,
on2fa () {
return prompt('Enter code')
}
}
});
然而,当我在node js中运行这个时(将这个\u用户名和这个\u密码设置为我的github用户名和密码),我得到了以下错误:
Uncaught Error: [@octokit/auth-token] Token passed to createTokenAuth is not a string
at Object.createTokenAuth (D:\github\sos\collector-dev\web\node_modules\@octokit\auth-token\dist-node\index.js:39:11)
at new Octokit (D:\github\sos\collector-dev\web\node_modules\@octokit\core\dist-node\index.js:115:32)
at new _a (D:\github\sos\collector-dev\web\node_modules\@octokit\core\dist-node\index.js:167:30)
at new OctokitWithDefaults (D:\github\sos\collector-dev\web\node_modules\@octokit\core\dist-node\index.js:147:9)
有趣的是,当我故意输入错误的密码时,我会收到相同的错误消息
对我错过的任何一步有什么想法吗?或者我误解了octokit要求的用户名和密码吗?正如您所提到的,这是一种不推荐使用的方法,不建议使用它。尽管如此,我还是发现了一个关于如何让它工作的讨论(直到Github决定完全关闭):
const octokit = new Octokit({
authStrategy: createBasicAuth,
auth: {
username: this_username,
password: this_password
}
});