# Setting auth token for Private Packagist (packagist.com)

**URL:** https://discourse.roots.io/t/setting-auth-token-for-private-packagist-packagist-com/21173
**Category:** trellis
**Tags:** composer
**Created:** 2021-07-22T20:49:42Z
**Posts:** 3

## Post 1 by @needle — 2021-07-22T20:49:42Z

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](https://github.com/roots/trellis/pull/1091) 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

---

## Post 2 by @needle — 2021-07-23T02:40:33Z

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.

---

## Post 3 by @system — 2021-09-02T22:20:44Z

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