Command line tools
Use an alias token to connect an external tool to XNAT. Choose the client that suits your workflow.
Choose a tool
Section titled “Choose a tool”Install
Section titled “Install”Install xnatutils from PyPI:
pip3 install xnatutilsAuthenticate with an alias token
Section titled “Authenticate with an alias token”Create a .netrc file in your home directory and add your XNAT server, alias and secret:
machine https://xnat.rcc.uq.edu.auuser <your-alias>password <your-alias-secret>Install
Section titled “Install”Install xnatpy from PyPI. The package name is xnat:
pip install xnatAuthenticate with an alias token
Section titled “Authenticate with an alias token”Pass your alias and secret when you create a session:
import xnat
with xnat.connect( 'https://xnat.rcc.uq.edu.au', user='<your-alias>', password='<your-alias-secret>',) as session: print(session.projects)Install
Section titled “Install”Install pyxnat from PyPI:
pip install pyxnatAuthenticate with an alias token
Section titled “Authenticate with an alias token”Pass your alias and secret when you create an interface:
from pyxnat import Interface
xnat = Interface( server='https://xnat.rcc.uq.edu.au', user='<your-alias>', password='<your-alias-secret>',)print(xnat.select.projects().get())Protect your credentials
Section titled “Protect your credentials”Do not commit an alias or secret to source control. Restrict access to a .netrc file on Linux or macOS:
chmod 600 ~/.netrcRevoke the alias token in XNAT when you no longer need it or if its secret may have been exposed.