Search code examples
gradlemaven-publishgithub-package-registry

Why does Github Package Registry say my token is not scoped to read packages?


I'm trying to publish a Gradle project. I have followed all the documentation provided by GitHub, but when I send the command to publish I am getting a 401 error from the server.

Execution failed for task ':publishGprPublicationToGitHubPackagesRepository'.
> Failed to publish publication 'gpr' to repository 'GitHubPackages'
   > Could not GET 'https://maven.pkg.github.com/PowerInnovations/Data-Model/com/powerinnovations/data-model/0.0.1-SNAPSHOT/maven-metadata.xml'. Received status code 401 from server: Unauthorized

Upon going to the page and logging in to Github, it says:

Your token has not been granted the required scopes to execute this query. The 'id' field requires one of the following scopes: ['read:packages'], but your token has only been granted the: [''] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.

The thing is, I am already using the personal access token which I created to do this, and it does have the read packages scope enabled.


Solution

  • I did get a resolution from a member of Github's support.

    The support person said in an email "When publishing packages, your PAT needs the repo scope as well as write access to the repo you package will be associated with."

    They agreed that the response from the server, in this case, was misleading.