Step 2: Authenticate Your Requests
The Scenario API supports two authentication methods: Basic Authentication (API Key + Secret) and Bearer Authentication (JWT token).
Method 1: Basic Authentication
Section titled “Method 1: Basic Authentication”Use your API Key and API Secret, joined by a colon and Base64-encoded.
1. Combine Key and Secret:
YOUR_API_KEY:YOUR_API_SECRET
2. Base64 Encode the Combined String:
For example, if YOUR_API_KEY is hello and YOUR_API_SECRET is world, the combined string is hello:world. The Base64 encoding of hello:world is aGVsbG86d29ybGQ=.
3. Construct the Authorization Header:
Authorization: Basic aGVsbG86d29ybGQ=
curl -u "YOUR_API_KEY:YOUR_API_SECRET" \ https://api.cloud.scenario.com/v1/userPython
Section titled “Python”from scenario_sdk import Scenario
client = Scenario( api_key="YOUR_API_KEY", api_secret="YOUR_API_SECRET",)
response = client.users.get()print(response)TypeScript
Section titled “TypeScript”import Scenario from '@scenario-labs/sdk';
const client = new Scenario({ apiKey: 'YOUR_API_KEY', apiSecret: 'YOUR_API_SECRET',});
const data = await client.users.get();console.log(data);Method 2: Bearer Authentication (JWT)
Section titled “Method 2: Bearer Authentication (JWT)”If you have a JWT token, you can use Bearer authentication instead.
curl -H "Authorization: Bearer YOUR_JWT_TOKEN" \ https://api.cloud.scenario.com/v1/userPython
Section titled “Python”from scenario_sdk import Scenario
client = Scenario( bearer_auth="YOUR_JWT_TOKEN",)
response = client.users.get()print(response)TypeScript
Section titled “TypeScript”import Scenario from '@scenario-labs/sdk';
const client = new Scenario({ bearerAuth: 'YOUR_JWT_TOKEN',});
const data = await client.users.get();console.log(data);