Skip to content

No token provided

The following details provide a summary of the No token provided error, explain the cause, and present recommended solutions.

What happens

When you send a request to a CalypsoAI endpoint without providing an authorization token, the request fails.

The following fragment of a full error response shows you the key part.

python
calypsoai.clients.base.RequestError: 'GET https://www.us1.calypsoai.app/backend/v1/campaigns'
responded with status 401
No token provided

Why it happens

The CalypsoAI API requires an authorization token to be provided in all requests to verify that the request is sent by an authorized user. If the authorization token is missing, our API can't authenticate the request and responds with the No token provided error.

The following sample shows a request that triggers the No token provided error.

python
from calypsoai import CalypsoAI

# Define the URL and token for CalypsoAI
CALYPSOAI_URL="https://www.us1.calypsoai.app"
# TOKEN MISSING

# Initialize the CalypsoAI client
cai = CalypsoAI(url=CALYPSOAI_URL)

# Get all campaigns
campaigns = [campaign.model_dump_json() for campaign in cai.campaigns.iterate()]
print(campaigns)

How to fix it

To resolve the issue, make sure you provide an authorization token in your request.

The following sample shows a correct request that includes an authorization token.

python
from calypsoai import CalypsoAI

# Define the URL and token for CalypsoAI
CALYPSOAI_URL="https://www.us1.calypsoai.app"
CALYPSOAI_TOKEN = "ADD-YOUR-TOKEN-HERE"

# Initialize the CalypsoAI client
cai = CalypsoAI(url=CALYPSOAI_URL, token=CALYPSOAI_TOKEN)

# Get all campaigns
campaigns = [campaign.model_dump_json() for campaign in cai.campaigns.iterate()]
print(campaigns)

Updated at: