{% extends "base.html" %} {% block title %}Authentication Documentation{% endblock %} {% block content %}

Authentication Documentation

Learn how to authenticate users in your application using the FastCMS API or JavaScript SDK.

1. Login with Email & Password

Authenticate a user and receive an access token.

cURL
curl -X POST "/api/v1/auth/login" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@example.com",
    "password": "password123"
  }'
JavaScript SDK
import FastCMS from 'fastcms';

const cms = new FastCMS('http://localhost:8000');

await cms.authWithPassword('user@example.com', 'password123');
console.log(cms.token); // Access token

2. Register New User

Create a new user account.

cURL
curl -X POST "/api/v1/auth/register" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "new@example.com",
    "password": "password123",
    "password_confirm": "password123",
    "name": "New User"
  }'
JavaScript SDK
// SDK currently handles registration via collection create
await cms.collection('users').create({
    email: 'new@example.com',
    password: 'password123',
    passwordConfirm: 'password123',
    name: 'New User'
});

3. OAuth Login (Google, GitHub, etc.)

Initiate OAuth flow. Redirect the user to this URL.

URL Pattern
GET /api/v1/oauth/login/{provider}?collection={collection_name}

Examples:

  • /api/v1/oauth/login/google (Login as system user)
  • /api/v1/oauth/login/github?collection=customers (Login as customer)

4. Refresh Token

Get a new access token using a refresh token.

cURL
curl -X POST "/api/v1/auth/refresh" \
  -H "Content-Type: application/json" \
  -d '{
    "refresh_token": "YOUR_REFRESH_TOKEN"
  }'
{% endblock %}