> ## Documentation Index
> Fetch the complete documentation index at: https://anaconda.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 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 (A randomly generated string that proves your identity and permission to access resources like channels, packages, or APIs.). For more information, see [Tokens](https://anaconda.com/docs/psm-on-prem/6.8.0/user/auth_token.md).

## Python packages

Twine is a popular tool for uploading Python packages (Software files and information about the software, such as its name, version, and description, bundled into a file that can be installed and managed by a package manager.) to repositories. For information on setting your username and password using the configuration file or environment variables, see the official [Twine package documentation](https://twine.readthedocs.io/en/latest/#configuration).

> [!NOTE]
>
> Package Security Manager 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](https://pip.pypa.io/en/stable/user_guide/#configuration).

> [tab] Uploading
>
> To upload your Python packages using `Twine`, run the following command:
>
> ```sh theme={null}
> # 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**
>
> ```sh theme={null}
> 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.

> [tab] Installing
>
> To install a `pip` package, run the following command:
>
> ```sh theme={null}
> # 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**
>
> ```sh theme={null}
> pip install --trusted-host demo-repo.com --index-url http://46e98d3dbf2378bb26e2107867652ee734eb098ea5b96f35:[[email protected]](/cdn-cgi/l/email-protection)/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.

> [tab] Uploading
>
> To upload R packages, run the following command:
>
> ```sh theme={null}
> # 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**
>
> ```sh theme={null}
> 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.

> [tab] Installing
>
> You can use your domain as a repository (Any storage location from which software or software assets, like packages, can be retrieved and installed on a local computer.) URL in the `install.packages` function by injecting a token into the path.
>
> To install an `R` package, run the following command:
>
> ```sh theme={null}
> # 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**
>
> ```sh theme={null}
> install.packages("leaflet", repos="http://demo-repo.com/api/t/46e98d3dbf2378bb26e2107867652ee734eb098ea5b96f35/repo/alex-pip/cran")
> ```
