Setting auth token for Private Packagist (packagist.com)

I recently upgraded to Trellis 1.4.0, which offers a different way to set the auth token for Private Packagist. Unfortunately I can’t seem to get it to work. I can’t find any instructions in the official docs, but this pull request lays it out clearly enough.

Using that PR as a guide, I have in group_vars/staging/vault.yml

vault_wordpress_sites:
  mydomain.com:
    composer_authentications:
      - { hostname: my-staging-domain.xyz, username: my-packagist-username, password: my-packagist-token }
  ...

I think that’s all I need, however when running trellis provision staging it completes successfully, but the composer authentications task never shows in the output. I’m not sure why but it’s not happening. Then when I run trellis deploy staging it fails at Composer authentication.

====================== Failed downloading primetime/wp-plugin-activation-
manifest, trying the next URL (401: The
'https://repo.packagist.com/pack/dists/primetime/wp-plugin-activation-
manifest/1.1.1.0/rf252a27fbeb42581022923679e9ed476ff5b1128.zip' URL required
authentication. You must be using the interactive console to authenticate)
Warning from repo.packagist.com: ====================== AUTHENTICATION
FAILURE Username and authentication token required, see
https://packagist.com/profile/auth - this is not your regular password

Sure enough, when I ssh into staging, there’s no auth.json file to be found. I feel like I’m missing some step to get it to generate, but I can’t figure out what. Any tips?

ansible 2.8.20
trellis 1.4.0
vagrant 2.2.10

Turns out the hostname value needs to point to the source with which you are attempting to authenticate, and not the name of the site that is the target of the deployment. :man_facepalming: So in my case, all I needed to do was change hostname from my-staging-domain.xyz to repo.packagist.com (the hostname for Private Packagist) and now I’m able to deploy to staging and auth.json is created as expected.

2 Likes

This topic was automatically closed after 42 days. New replies are no longer allowed.