authenticationgitlabcomposer-phpsatispersonal-access-token

Composer - download package from private gitlab package registry - invalid credentials


I have a small pipeline to use a custom composer package into a project:

I added an entry in the repositories section of composer.json and added gitlab credentals with composer cli command

composer.json 'repositories' entry

"repositories": [
    {
        "type": "composer",
        "url": "https://gitlab.com/vendor/group/project"
    }
]

composer cli command for credentials

composer config gitlab-token.gitlab.com glpat-123456789abcdefgh

auth.json generated by composer cli

{
    "gitlab-token": {
        "gitlab.com": "glpat-123456789abcdefgh"
    }
}

error during composer require

Invalid credentials for 'https://gitlab.com/users/sign_in', aborting.

Solution

  • Ok, i did found a wrong documentation page.

    According to Install a Composer package the correct composer cli command to add the repository entry in composer.json is

    composer config repositories.<group_id> composer https://gitlab.example.com/api/v4/group/<group_id>/-/packages/composer/
    

    that leads to the entry

    "repositories": {
        "<group_id>": {
            "type": "composer",
            "url": "https://gitlab.example.com/api/v4/group/<group_id>/-/packages/composer/"
        },
        ...
    },