Search K
Appearance
Appearance
The following details provide a summary of the No token provided error, explain the cause, and present recommended solutions.
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.
calypsoai.clients.base.RequestError: 'GET https://www.us1.calypsoai.app/backend/v1/campaigns'
responded with status 401
No token providedThe 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.
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)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.
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)