即使生成了 GitHub 安装访问令牌,回调仍失败
callback failing even though GitHub Installation access Token gets generated
我有生成安装访问令牌的代码:
gitInstallationAccessToken.getAccessTokensUrl(jwt, function(appAccessTokensUrl) {
var instance = axios({
method: "POST",
url: appAccessTokensUrl,
headers: {
"Accept" : "application/vnd.github.machine-man-preview+json",
"Authorization" : `Bearer ${jwt}`
}
})
.then(function(response) {
var installationAccessToken = response.data.token;
console.log(`Installation Access Token: ${installationAccessToken}`)
callback(installationAccessToken);
})
.catch(function(error) {
console.warn("Unable to authenticate");
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
if (error.response) {
console.warn(`Status ${error.response.status}`);
console.warn(`${error.response.data.message}`);
}
});
});
它输出 Unable to authenticate
所以在某些时候失败了。我的问题是 console.log('Installation Access Token: ${installationAccessToken}')
输出一个令牌,所以我希望回调成功。有什么原因可能会失败吗?
附加信息
这是捕获中返回的实际错误:
ReferenceError: regeneratorRuntime is not defined
at eval (webpack:///./lib/githubService.js?:17:51)
at Object.retrieveIssues (webpack:///./lib/githubService.js?:87:6)
at eval (webpack:///./lib/getPublicGitHubIssues.js?:78:20)
at eval (webpack:///./lib/gitInstallationAccessToken.js?:84:9)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
看起来这可能与 this 的解决方案 2 有关。不过我不确定最后两个步骤会去哪里。
我安装了 babel-plugin-transform-regenerator
并在问题文件的顶部添加了 import 'babel-polyfill'
。似乎已经解决了这个问题,虽然它对我来说真的没有意义。
我有生成安装访问令牌的代码:
gitInstallationAccessToken.getAccessTokensUrl(jwt, function(appAccessTokensUrl) {
var instance = axios({
method: "POST",
url: appAccessTokensUrl,
headers: {
"Accept" : "application/vnd.github.machine-man-preview+json",
"Authorization" : `Bearer ${jwt}`
}
})
.then(function(response) {
var installationAccessToken = response.data.token;
console.log(`Installation Access Token: ${installationAccessToken}`)
callback(installationAccessToken);
})
.catch(function(error) {
console.warn("Unable to authenticate");
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
if (error.response) {
console.warn(`Status ${error.response.status}`);
console.warn(`${error.response.data.message}`);
}
});
});
它输出 Unable to authenticate
所以在某些时候失败了。我的问题是 console.log('Installation Access Token: ${installationAccessToken}')
输出一个令牌,所以我希望回调成功。有什么原因可能会失败吗?
附加信息
这是捕获中返回的实际错误:
ReferenceError: regeneratorRuntime is not defined
at eval (webpack:///./lib/githubService.js?:17:51)
at Object.retrieveIssues (webpack:///./lib/githubService.js?:87:6)
at eval (webpack:///./lib/getPublicGitHubIssues.js?:78:20)
at eval (webpack:///./lib/gitInstallationAccessToken.js?:84:9)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
看起来这可能与 this 的解决方案 2 有关。不过我不确定最后两个步骤会去哪里。
我安装了 babel-plugin-transform-regenerator
并在问题文件的顶部添加了 import 'babel-polyfill'
。似乎已经解决了这个问题,虽然它对我来说真的没有意义。