GitHub API 在 Appveyor 上未经授权的回复

Unauthorized response from GitHub API on Appveyor

我们刚刚开始一个新项目,并试图让 CI 通过 Appveyor 工作。 它是一个 Aurelia 网络应用程序,因此我们需要 jspm 在构建服务器上。

在我的工作站上,我 configured jspm manually 按照@guybedford 在他下面的回答中的建议,并在 appveyor.yml 脚本中配置了我的 authtoken:

  - jspm config registries.github.auth %JSPM_GITHUB_AUTH_TOKEN%

目前我的 appveyor.yml 看起来像这样,基于 Auto configuring section from JSPM

version: 1.0.{build}
os: Visual Studio 2015
build:
  verbosity: detailed
environment:
  JSPM_GITHUB_AUTH_TOKEN:#token from jspm registry export github (locally)#
install:
  - ps: Set-Culture nl-NL
  - ps: Install-Product node $env:nodejs_version
  - cd src\Web
  - npm uninstall jspm -g
  - npm install -g jspm
  - npm install -g gulp
  - npm install
  - jspm config registries.github.auth %JSPM_GITHUB_AUTH_TOKEN%
  - jspm config registries.github.maxRepoSize 0
  - jspm registry export github #output to see what the registry looks like
  - jspm install -y
  - gulp build
  - cd ..\..
nuget:
  account_feed: true
before_build:
  - dnvm install -r clr -arch x86 1.0.0-rc1-update1
  - dnu restore
  - nuget restore

jspm install - y 命令失败并出现错误:Unauthorized response for GitHub API

如何在 AppVeyor 上使用 JSPM 正确配置 Github 凭据?

最好在本地配置凭据后从 jspm registry export github 获取此令牌,以便使用与 jspm 完全相同的算法而不是进行手动编码。

如果真要手动编码,auth token其实取值new Buffer(encodeURIComponent(username) + ':' + encodeURIComponent(password)).toString('base64')

在与 Appveyor 团队联系后,我们发现问题出在节点版本上。 安装 Node 的稳定版本非常有效:

ps: Install-Product node stable