Skip to content

Authenticate Client via Dotenv#

For our V1 authentication requirements, assume our client id is 7p3Hw9YMqnfxaIvKc4 and our client secret is Qxm^^3h(7ZK994U8M%/g!YFo2VEPs*k!. Let's also assume we have a token of a5b2c3a7-9385-47e4-80b8-a445f842e403 and an expires at 1781373801.

How do I get my client id and secret?

Please refer to the Register a V1 App guide to learn how to obtain your client id and secret.

How do I get my token?

Please refer to the Generate a V1 Token guide to learn how to obtain your token.

For our V2 authentication requirements, assume our username is [email protected] and our password is password123.

First, make a Dotenv (.env) file in your project directory with the following content:

.env
PYTICKTICK_V1_CLIENT_ID=7p3Hw9YMqnfxaIvKc4
PYTICKTICK_V1_CLIENT_SECRET=Qxm^^3h(7ZK994U8M%/g!YFo2VEPs*k!
PYTICKTICK_V1_TOKEN_VALUE=a5b2c3a7-9385-47e4-80b8-a445f842e403
PYTICKTICK_V1_TOKEN_EXPIRATION=1781373801

Then, you can create the client like this:

from pyticktick import Client

client = Client(_env_file=".env")

No V2 Access

This client will not be able to use V2 functions without authenticating with V2 credentials.

First, make a Dotenv (.env) file in your project directory with the following content:

.env
[email protected]
PYTICKTICK_V2_PASSWORD=password123

Then, you can create the client like this:

from pyticktick import Client

client = Client(_env_file=".env")

No V1 Access

This client will not be able to use V1 functions without authenticating with V1 credentials.

First, make a Dotenv (.env) file in your project directory with the following content:

.env
PYTICKTICK_V1_CLIENT_ID=7p3Hw9YMqnfxaIvKc4
PYTICKTICK_V1_CLIENT_SECRET=Qxm^^3h(7ZK994U8M%/g!YFo2VEPs*k!
PYTICKTICK_V1_TOKEN_VALUE=a5b2c3a7-9385-47e4-80b8-a445f842e403
PYTICKTICK_V1_TOKEN_EXPIRATION=1781373801
[email protected]
PYTICKTICK_V2_PASSWORD=password123

Then, you can create the client like this:

from pyticktick import Client

client = Client(_env_file=".env")

To see more on env file support, please refer to Pydantic Settings' Dotenv (.env) support.