Authentication for composer private repository in composer.json file

Viewed 414

I have a composer package in a Gitlab project, and am using the following composer.json structure to pull in the package:

"repositories": [
    {
        "type": "vcs",
        "url": "https://git.example.com/amarjit/my-package.git"
    }
]

Now every time I install a package or do anything using the composer command I have to give credentials for the "my-package" repository. I have created an access token on GitLab with "read only" access to the "my-package" repository and I googled how to use access token with private composer packages, but all of the results suggested saving token in auth.json.

But if I do that then all other developers of the project will also have to do the same in their environment. So Is there any way to save authentication info in composer.json. I know I can put my username and password in the URL attribute inside composer.json. But I don't want to share my creds with other devs.

How I can save the read-only access token in composer.json so that composer doesn't ask for GitLab credentials?

0 Answers
Related