Skip to content
Last updated

Authentication

The vFairs API uses industry-standard authentication methods to ensure secure access to your event data. We support OAuth 2.0 with client credentials flow for server-to-server integrations.

Authentication Methods

OAuth 2.0 with client credentials flow is the recommended authentication method for server-to-server integrations.

Security Scheme TypeHTTP
HTTP Authorization SchemeBearer
Bearer FormatOAuth

Getting Your Credentials

Steps to Obtain "App Key" & "App Secret" for Access Token:

  1. Log in to your event backend and navigate to Event Setup.
  2. Go to the API tab and click to open it.
  3. Click the Generate Secret button on the right side.
  4. Enter a name for your secret key (e.g., "Secret Key" or "ABC") and click the Update button.
  5. Use the App Key and Secret Key to obtain the access token.

For more details, refer to the following image:

ENV Configuration

Important: Store your credentials securely and never expose them in client-side code or public repositories.

Obtaining an Access Token

Make a POST request to the token endpoint:

Request:

curl -X POST "https://api.vfairs.com/v1/auth/token" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials" \
  -d "client_id=YOUR_CLIENT_ID" \
  -d "client_secret=YOUR_CLIENT_SECRET"

Response:

{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "read:events read:attendees read:sessions"
}

Using the Access Token

Include the access token in the Authorization header of your API requests:

curl -X GET "https://api.vfairs.com/v1/events" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

API Key Authentication

For simpler integrations, you can use API key authentication by including your API key in the request headers.

curl -X GET "https://api.vfairs.com/v1/events" \
  -H "X-API-Key: YOUR_API_KEY"

Token Management

Token Expiration

Access tokens expire after 1 hour (3600 seconds). Your application should:

  1. Check the expires_in field in the token response
  2. Refresh tokens before they expire
  3. Handle 401 Unauthorized responses by obtaining a new token

Token Refresh

Since we use the client credentials flow, simply request a new token when the current one expires:

async function getAccessToken() {
  const response = await fetch('https://api.vfairs.com/v1/auth/token', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: new URLSearchParams({
      'grant_type': 'client_credentials',
      'client_id': process.env.VFAIRS_CLIENT_ID,
      'client_secret': process.env.VFAIRS_CLIENT_SECRET,
    }),
  });
  
  const data = await response.json();
  return data.access_token;
}

Scopes

The vFairs API uses scopes to control access to different resources:

ScopeDescription
read:eventsRead access to events and event details
read:attendeesRead access to attendee information
read:sessionsRead access to session data
write:eventsWrite access to create and update events
write:attendeesWrite access to manage attendee data

Security Best Practices

Credential Storage

  • Store credentials as environment variables
  • Use secure credential management systems in production
  • Never commit credentials to version control

Token Security

  • Use HTTPS for all API requests
  • Implement token refresh logic
  • Monitor for unauthorized access

Rate Limiting

  • Respect rate limits to avoid being blocked
  • Implement exponential backoff for retries
  • Cache responses when possible

Error Handling

Authentication Errors

Status CodeError CodeDescription
401INVALID_CREDENTIALSInvalid client ID or secret
401EXPIRED_TOKENAccess token has expired
401INVALID_TOKENMalformed or invalid token
403INSUFFICIENT_SCOPEToken lacks required permissions

Example Error Response

{
  "status": "error",
  "code": "INVALID_CREDENTIALS",
  "message": "The provided client credentials are invalid",
  "details": {
    "timestamp": "2024-01-15T14:30:00Z",
    "request_id": "req_abc123"
  }
}

Code Examples

Python

import requests
import os

def get_access_token():
    url = "https://api.vfairs.com/v1/auth/token"
    data = {
        "grant_type": "client_credentials",
        "client_id": os.getenv("VFAIRS_CLIENT_ID"),
        "client_secret": os.getenv("VFAIRS_CLIENT_SECRET")
    }
    
    response = requests.post(url, data=data)
    response.raise_for_status()
    
    return response.json()["access_token"]

def make_api_request(endpoint):
    token = get_access_token()
    headers = {"Authorization": f"Bearer {token}"}
    
    response = requests.get(f"https://api.vfairs.com/v1/{endpoint}", headers=headers)
    response.raise_for_status()
    
    return response.json()

Node.js

const axios = require('axios');

async function getAccessToken() {
  const response = await axios.post('https://api.vfairs.com/v1/auth/token', {
    grant_type: 'client_credentials',
    client_id: process.env.VFAIRS_CLIENT_ID,
    client_secret: process.env.VFAIRS_CLIENT_SECRET,
  }, {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  });
  
  return response.data.access_token;
}

async function makeApiRequest(endpoint) {
  const token = await getAccessToken();
  
  const response = await axios.get(`https://api.vfairs.com/v1/${endpoint}`, {
    headers: {
      Authorization: `Bearer ${token}`,
    },
  });
  
  return response.data;
}

Testing Authentication

You can test your authentication setup using curl:

# Test token endpoint
curl -X POST "https://api.vfairs.com/v1/auth/token" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET"

# Test API access
curl -X GET "https://api.vfairs.com/v1/events" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Support

If you encounter authentication issues:

  1. Verify your credentials are correct
  2. Check that your account has API access enabled
  3. Review the error response for specific details
  4. Contact integrations@vfairs.com for assistance