Skip to content

electron-updater 套件的 addAuthHeader(token) 無法用於 gitlab private repository #9043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
misk0225 opened this issue Apr 22, 2025 · 1 comment · May be fixed by #9044
Open

electron-updater 套件的 addAuthHeader(token) 無法用於 gitlab private repository #9043

misk0225 opened this issue Apr 22, 2025 · 1 comment · May be fixed by #9044

Comments

@misk0225
Copy link

misk0225 commented Apr 22, 2025

Electron-Updater: 6.6.3
Npm: 10.2.4

說明

class AutoUpdater 內的 addAuthHeader(token) 內部實作為:

// 無法用於 gitlab private repository 身分驗證
addAuthHeader(token) {
    this.requestHeaders = Object.assign({}, this.requestHeaders, {
        authorization: token,
    });
}

不過對於 gitlab private repository,requestHeaders 需使用 'PRIVATE-TOKEN' 而非 authorization 欄位,例如:

// success !
addAuthHeader(token) {
    this.requestHeaders = Object.assign({}, this.requestHeaders, {
        'PRIVATE-TOKEN': token,
    });
}
@misk0225 misk0225 linked a pull request Apr 22, 2025 that will close this issue
@mmaietta mmaietta linked a pull request Apr 24, 2025 that will close this issue
@misk0225
Copy link
Author

How

This is my package.json.

"publish": {
  "provider": "generic",
  "url": "http://<gitlab-name>/api/v4/projects/558/jobs/artifacts/release/raw/release/build?job=package-project",   
  "channel": "latest" 
}

My GitLab instance is not gitlab.com, but a self-hosted private GitLab set up by our company. The domain looks like http://123.456.78.901/api/..., and the URL points to the GitLab API, which we use to fetch the latest CI/CD build artifacts.

Also, here is the official documentation for the API. I used it to get the latest version of latest.yml.
https://docs.gitlab.com/api/job_artifacts/#download-a-single-artifact-file-from-specific-tag-or-branch

Finally, I called the electron-updater method:

log.transports.file.level = 'info'
autoUpdater.addAuthHeader('my-gitlab-token')
autoUpdater.autoDownload = true
autoUpdater.autoInstallOnAppQuit = false
autoUpdater.logger = log
const checkRes = await autoUpdater.checkForUpdates()

Result

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant