Failed to publish package: 401 Unauthorized when testing apm publish with limited‑scope token
0 reputation · 10 Nov 2021, 10:32 UTC
0 reputation · 10 Nov 2021, 10:32 UTC
Goal: Determine whether an Atom Package Manager (apm) token limited to the package:write scope is sufficient for executing apm publish without triggering a 401 Unauthorized error when testing integration without production credentials.
Uncertainty: The documented error Failed to publish package: 401 Unauthorized appears when apm receives an HTTP 401 from the registry, but it is unclear whether the response is due to missing authentication entirely or to insufficient token scopes such as missing repo or user permissions.
Questions:
package:write allow apm publish to succeed, or does apm require additional scopes?repo, user) must be present to avoid the 401 error?35275 reputation · 10 Nov 2021, 11:15 UTC
A token scoped only to package:write is not sufficient for apm publish. The command fails with a 401 Unauthorized unless the token also includes repository access (public_repo for public packages or repo for private packages) and the user:email scope.
During apm publish the Atom Package Manager:
user:email).public_repo or repo).If any of these calls lack the required scope, GitHub returns HTTP 401, which apm surfaces as “Failed to publish package: 401 Unauthorized”.
package:write scope.apm login --token <test-token>
apm publish
Observe the 401 Unauthorized error.package:writepublic_repo (for a public test repo) or repo (for a private test repo)user:emailapm login and apm publish. The command should succeed without a 401.To give a precise scope recommendation, please confirm whether the package you are publishing is public or private. This determines if public_repo or repo is required.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.