Skip to content

gh auth token scopes not valid for ghcr #5174

Closed

Description

@xzyfer

Describe the bug

The token generated by gh auth login --scopes read:packages does not respected by ghcr.io.

❯ gh --version
gh version 2.5.0 (2022-02-01)
https://github.com/cli/cli/releases/tag/v2.5.0

Steps to reproduce the behavior

Login via gh

gh auth login --hostname github.com --web --scopes read:packages

Using the generated token

gh auth status --show-token

Login via the docker cli

echo "<token>" | docker login ghcr.io --username <username> --password-stdin

Pull private or internal docker image from ghcr.io

docker pull ghcr.io/<org>/<repo>:latest

Expected vs actual behavior

It's expected that the tokens generated via gh auth (given the read:packages scope) will be able to docker pull images that have private or internal visibility -- this is the case for PATs.

Instead the following error is produced Error response from daemon: unauthorized.

Activity

  1. maxekman commented on Feb 7, 2022

    @maxekman

    Would love to see this solved!

  2. odsod commented on Feb 7, 2022

    @odsod

    @xzyfer I ran into the same issue, and for me it was that the GHCR images were stored in an SSO-protected organization. It might be that gh auth login needs to support SSO authorizing the generated token.

  3. xzyfer commented on Feb 7, 2022

    @xzyfer
    Author

    I can confirm new do not have SSO. Other authenticated operations via gh work fine. The issue appears to be related specifically to ghcr's auty model.

  4. mislav commented on Feb 7, 2022

    @mislav
    Contributor

    Ah, so, I've learned something today: for docker login ghcr.io you can only use Personal Access Tokens that you manually generate and additionally SSO for your org. Right now it seems that you cannot use the token produced by gh auth login since that's technically an OAuth token (and not a PAT). 🤔

    I will ask internally whether this restriction is intentional or not.

  5. added
    platformProblems with the GitHub platform rather than the CLI client
    and removed on Feb 7, 2022
  6. mislav commented on Feb 8, 2022

    @mislav
    Contributor

    This is not resolved, but I'm going to fold this into #5150 so we have a single issue to track Docker authentication stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-investigationCLI team needs to investigateplatformProblems with the GitHub platform rather than the CLI client

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions