{% extends "base.html" %} {% block title %}Authentication Documentation{% endblock %} {% block content %}
Learn how to authenticate users in your application using the FastCMS API or JavaScript SDK.
Authenticate a user and receive an access token.
curl -X POST "/api/v1/auth/login" \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "password123"
}'
import FastCMS from 'fastcms';
const cms = new FastCMS('http://localhost:8000');
await cms.authWithPassword('user@example.com', 'password123');
console.log(cms.token); // Access token
Create a new user account.
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"
}'
// SDK currently handles registration via collection create
await cms.collection('users').create({
email: 'new@example.com',
password: 'password123',
passwordConfirm: 'password123',
name: 'New User'
});
Initiate OAuth flow. Redirect the user to this URL.
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)Get a new access token using a refresh token.
curl -X POST "/api/v1/auth/refresh" \
-H "Content-Type: application/json" \
-d '{
"refresh_token": "YOUR_REFRESH_TOKEN"
}'