Search code examples
phabricator

How to pull a password from Phabricator's Passphrase


How do I pull a password saved in Phabricator's Passphrase Application?

Let's assume that we've added a password titled "My Password" to Passphrase application, now we want to reuse this password in some automation software so we need a way to pull a password using command-line or something. How would you do it?


Solution

  • You can make it using Conduit API and passphrase.query.

    To learn how to use it you should go to https://your-phabricator.com/conduit/method/passphrase.query/

    1. Locate your credential key, e.g. "K1".
    2. Open credential and "Allow Conduit Access".
    3. Locate Conduit API CLI token on page https://your-phabricator.com/settings/panel/apitokens/
    4. Use either arc or curl command to issue query:

    echo '{"ids": [1], "needSecrets": 1}' | arc call-conduit --conduit-uri https://your-phabricator.com/ --conduit-token  passphrase.query
    

    
    curl https://your-phabricator.com/api/passphrase.query \
      -d api.token=api-token \
      -d ids[0]=1 \
      -d needSecrets=1
    

    1. The output can be piped further through jq:

    curl https://your-phabricator.com/api/passphrase.query \
      -d api.token=api-token \
      -d ids[0]=1 \
      -d needSecrets=1 | jq -r '.result.data[].material.password'