Authentication
Authentication is required to access protected resources in the Gatsby API. This page provides a brief overview of the authentication process. For detailed endpoint documentation, refer to the Auth section.
Authentication Flow
To use the Gatsby REST API, you need to:
- Log in with your email and password to obtain an access token
- Include this token in all subsequent requests in the
Authorization
header - Include your organization slug in the
organizationSlug
header
All requests (except for login) require both the access token and organization slug to be present in the headers.
Required Headers
After authenticating, include these headers in all your API requests:
Authorization: Bearer {accessToken}
organizationSlug: {organizationSlug}
Example Authentication Flow
Authentication Example
import axios from 'axios';
// Step 1: Login to get access token
const loginResponse = await axios.post('https://rest.gatsby.events/login', {
email: '[email protected]',
password: 'your-password'
});
const { accessToken, organizationSlugs } = loginResponse.data;
const organizationSlug = organizationSlugs[0]; // Choose an organization
// Step 2: Setup headers for future requests
axios.defaults.headers.common['Authorization'] = `Bearer ${accessToken}`;
axios.defaults.headers.common['organizationSlug'] = organizationSlug;
// Step 3: Make authenticated requests
const response = await axios.get('https://rest.gatsby.events/person');
Error Handling
When an authentication error occurs, the API will return a 401 Unauthorized status code along with an error message in the response body. Always check response status codes and handle authentication errors appropriately in your application.
For detailed information about authentication endpoints, please refer to the Auth section.