Getting Started

Code Examples

Ready-to-use integration examples for every supported platform.

Integration Guides

Quick Start — cURL

Terminal
# 1. Generate an SSO token
curl -X POST https://your-cas-server.com/api/sso/token \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "SecureP@ss123!",
    "client_id": "your_client_id",
    "client_secret": "your_client_secret"
  }'

# 2. Validate the token
curl -X POST https://your-cas-server.com/api/sso/validate \
  -H "Content-Type: application/json" \
  -d '{"token": "eyJhbGci..."}'

JavaScript — Fetch API

auth.js
async function generateToken(email, password) {
  const res = await fetch('https://your-cas-server.com/api/sso/token', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ email, password,
      client_id: 'your_client_id',
      client_secret: 'your_client_secret'
    })
  });
  return res.json();
}

async function validateToken(token) {
  const res = await fetch('https://your-cas-server.com/api/sso/validate', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ token })
  });
  return res.json();
}

PHP — cURL

CasAuth.php
function generateSSOToken($email, $password) {
    $ch = curl_init('https://your-cas-server.com/api/sso/token');
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST           => true,
        CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
        CURLOPT_POSTFIELDS     => json_encode([
            'email'         => $email,
            'password'      => $password,
            'client_id'     => 'your_client_id',
            'client_secret' => 'your_client_secret',
        ]),
    ]);
    $response = curl_exec($ch);
    curl_close($ch);
    return json_decode($response, true);
}

Python — Requests

cas_auth.py
import requests

def generate_token(email, password):
    response = requests.post(
        'https://your-cas-server.com/api/sso/token',
        json={
            'email': email,
            'password': password,
            'client_id': 'your_client_id',
            'client_secret': 'your_client_secret',
        }
    )
    return response.json()