Working with private channels using third-party tools#

In order to access private channels via third-party tools (such as pip, Twine, or R), you must have a resource token. For more information, see Tokens.

Python packages#

Twine is a popular tool for uploading Python packages to repositories. For information on setting your username and password using the configuration file or environment variables, see the official Twine package documentation.

Note

Package Security Manager (On-prem) supports user authentication using Basic Authentication. For information on setting your index URL using the configuration file or environment variables, see the official pip documentation.

To upload your Python packages using Twine, run the following command:

# Replace <FQDN> with your Package Security Manager fully qualified domain name
# Replace <CHANNEL> with the name of the channel you want to upload your package to
# Replace <PACKAGE> with the name of the package you are uploading
# Replace <TOKEN> with a resource token that provides access to the channel
twine upload --repository-url http://<FQDN>/api/repo/<CHANNEL> <PACKAGE> -u <TOKEN> -p x-auth-token

Example

twine upload --repository-url http://demo-repo.com/api/repo/my-pip-channel six-1.13.0-py2.py3-none-any.whl -u 46e98d3dbf2378bb26e2107867652ee734eb098ea5b96f35 -p x-auth-token

Note

If you are receiving a 401 error message, your token is incorrect.

To install a pip package, run the following command:

# Replace <FQDN> with your Package Security Manager fully qualified domain name
# Replace <CHANNEL> with the name of the channel that contains your package
# Replace <PACKAGE> with the name of the package you are installing
# Replace <TOKEN> with a resource token that provides access to the channel
pip install --trusted-host <FQDN> --index-url http://<TOKEN>:x-auth-token@<FQDN>/api/repo/<CHANNEL>/simple <PACKAGE>

Example

pip install --trusted-host demo-repo.com --index-url http://46e98d3dbf2378bb26e2107867652ee734eb098ea5b96f35:[email protected]/api/repo/alex-pip/simple six

R packages#

There is no standard tool for uploading R packages. Upload your R packages using either the UI or API directly.

To upload R packages, run the following command:

# Replace <FQDN> with your Package Security Manager fully qualified domain name
# Replace <CHANNEL> with the name of the channel you want to upload your package to
# Replace <PACKAGE> with the name of the package you are uploading
# Replace <TOKEN> with a resource token that provides access to the channel
curl -v -F filetype=cran_source_package -F content=@<PACKAGE> http://<FQDN>/api/repo/<CHANNEL> -H"X-Auth: <TOKEN>"

Example

curl -v -F filetype=cran_source_package -F content=@abc_2.1.tar.gz http://demo-repo.com/api/repo/alex-pip -H"X-Auth: 46e98d3dbf2378bb26e2107867652ee734eb098ea5b96f35"

Note

Use cran_source_package for source packages and cran_binary_package for binary R packages.

You can use your domain as a repository URL in the install.packages function by injecting a token into the path.

To install an R package, run the following command:

# Replace <FQDN> with your Package Security Manager fully qualified domain name
# Replace <CHANNEL> with the name of the channel that contains your package
# Replace <PACKAGE> with the name of the package you are installing
# Replace <TOKEN> with a resource token that provides access to the channel
install.packages("<PACKAGE>", repos="http://<FQDN>/api/repo/t/<TOKEN>/<CHANNEL>/cran")

Example

install.packages("leaflet", repos="http://demo-repo.com/api/t/46e98d3dbf2378bb26e2107867652ee734eb098ea5b96f35/repo/alex-pip/cran")