ReferenceClientAuthentication

Authentication

Comprehensive guide for authenticating Synnax clients.

This guide covers all authentication methods and connection parameters for the Synnax clients. If you’re looking for a quick start, check out the Quick Start guide instead.

Authentication Methods

There are three ways to authenticate with a Synnax Core: using the CLI to permanently store your credentials, passing your credentials directly to the client, or configuring environment variables.

  • For instructions on direct authentication, see Create a Client.
  • CLI authentication is only supported in the Python client.
ParameterDescription
hostThe hostname of the Synnax Core
portThe port of the Synnax Core
usernameThe username to authenticate with
passwordThe password to authenticate with.
secureWhether to use TLS encryption.

CLI Authentication (Python Only)

The easiest way to authenticate with a Core is with the login command. This will permanently store your credentials in the operating system’s keychain.

This method is highly recommended, as it makes it easy to share scripts without accidentally revealing credentials.

In the terminal, run the following command:

sy login

If you get the error command not found, see our troubleshooting guide.

The CLI will prompt for additional information:

Enter your Synnax connection parameters:
Host (localhost): # YOUR HOST
Port (9090): # YOUR PORT
Username (synnax): # YOUR USERNAME
Password: # YOUR PASSWORD
Secure connection? (y/n) (n):

You should then see the following message:

Saved credentials. You can now use the Synnax Client
without having to log in. To connect to the Core in a Python shell, use the following:

from synnax import Synnax
client = Synnax()

Environment Variables

You can store your connection parameters as environment variables to keep them out of your code. This is useful for production deployments or when working with multiple environments.

Setting environment variables

Select your operating system below to see how to set environment variables:

Using environment variables in code

Python

TypeScript

import os
import synnax as sy

client = sy.Synnax(
    host=os.environ["SYNNAX_HOST"],
    port=int(os.environ["SYNNAX_PORT"]),
    username=os.environ["SYNNAX_USERNAME"],
    password=os.environ["SYNNAX_PASSWORD"],
    secure=os.environ.get("SYNNAX_SECURE", "false").lower() == "true"
)