The ScientistCloud API uses JWT (JSON Web Token) authentication. This guide explains how to authenticate and use tokens.
Authentication is a two-step process:
/api/auth/loginLogin with your email address to receive an access token.
Request:
curl -X POST "https://scientistcloud.com/api/auth/login" \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com"}'
Request Body:
{
"email": "user@example.com"
}
Response:
{
"success": true,
"message": "Login successful",
"data": {
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"expires_in": 86400,
"token_type": "Bearer",
"user": {
"user_id": "user_abc123",
"email": "user@example.com",
"name": "User Name",
"email_verified": true
}
}
}
Extract Token:
TOKEN=$(curl -s -X POST "https://scientistcloud.com/api/auth/login" \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com"}' | \
jq -r '.data.access_token')
Include the token in the Authorization header for all authenticated requests:
curl -H "Authorization: Bearer $TOKEN" \
"https://scientistcloud.com/api/auth/status"
/api/auth/statusVerify that your token is valid.
Request:
curl -H "Authorization: Bearer $TOKEN" \
"https://scientistcloud.com/api/auth/status"
Response:
{
"is_authenticated": true,
"user_email": "user@example.com",
"access_type": "direct",
"error": null
}
/api/auth/meGet information about the authenticated user.
Request:
curl -H "Authorization: Bearer $TOKEN" \
"https://scientistcloud.com/api/auth/me"
Response:
{
"user_id": "user_abc123",
"email": "user@example.com",
"name": "User Name",
"email_verified": true
}
/api/auth/refreshRefresh an expired access token using a refresh token.
Request:
curl -X POST "https://scientistcloud.com/api/auth/refresh" \
-H "Content-Type: application/json" \
-d '{"refresh_token": "YOUR_REFRESH_TOKEN"}'
Response:
{
"success": true,
"message": "Token refreshed successfully",
"data": {
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"expires_in": 86400,
"token_type": "Bearer"
}
}
/api/auth/logoutLogout endpoint accepts a token in the JSON request body.
Request:
curl -X POST "https://scientistcloud.com/api/auth/logout" \
-H "Content-Type: application/json" \
-d "{\"token\":\"$TOKEN\"}"
Response:
{
"success": true,
"message": "Logout successful"
}
401 Unauthorized response. Simply login again to get a new token.
{
"success": false,
"error": "Invalid email or authentication failed",
"code": "AUTH_ERROR"
}
{
"success": false,
"error": "Token has expired",
"code": "TOKEN_EXPIRED"
}
{
"success": false,
"error": "Authentication required",
"code": "AUTH_REQUIRED"
}
#!/bin/bash
# 1. Login
echo "Logging in..."
TOKEN=$(curl -s -X POST "https://scientistcloud.com/api/auth/login" \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com"}' | \
jq -r '.data.access_token')
if [ -z "$TOKEN" ] || [ "$TOKEN" = "null" ]; then
echo "❌ Login failed"
exit 1
fi
echo "✅ Token obtained: ${TOKEN:0:20}..."
# 2. Verify token
echo "Verifying token..."
curl -s -H "Authorization: Bearer $TOKEN" \
"https://scientistcloud.com/api/auth/status" | jq
# 3. Get user info
echo "Getting user info..."
curl -s -H "Authorization: Bearer $TOKEN" \
"https://scientistcloud.com/api/auth/me" | jq
# 4. Use token for API calls
echo "Listing datasets..."
curl -s -H "Authorization: Bearer $TOKEN" \
"https://scientistcloud.com/portal/api/datasets" | jq
# 5. Logout
echo "Logging out..."
curl -s -X POST "https://scientistcloud.com/api/auth/logout" \
-H "Authorization: Bearer $TOKEN" | jq
# Check if token is valid
curl -H "Authorization: Bearer $TOKEN" \
"https://scientistcloud.com/api/auth/status"
# If expired, login again
TOKEN=$(curl -s -X POST "https://scientistcloud.com/api/auth/login" \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com"}' | \
jq -r '.data.access_token')
# Check service health
curl https://scientistcloud.com/health
# Should return: {"status": "healthy"}