ExamplesAuthentication

Authentication Flow Mocking

Mock complete authentication flows including login, token refresh, and protected endpoints.

For complete examples with detailed code, see the Authentication Flow Mocking section in MASTER_DOCUMENTATION.md.


Login Request

const loginRecording = createRecording(
  {
    method: 'POST',
    path: '/auth/login',
    body: { email: 'user@example.com', password: 'password123' },
    timestamp: Date.now()
  },
  {
    status: 200,
    body: {
      accessToken: 'eyJhbGc...',
      user: { id: '1', email: 'user@example.com' }
    },
    timestamp: Date.now()
  }
)

Protected Endpoint

const protectedRecording = createRecording(
  {
    method: 'GET',
    path: '/api/profile',
    headers: { 'Authorization': 'Bearer eyJhbGc...' },
    timestamp: Date.now()
  },
  {
    status: 200,
    body: { id: '1', email: 'user@example.com', name: 'Test User' },
    timestamp: Date.now()
  }
)

Full Documentation

See MASTER_DOCUMENTATION.md for complete authentication examples.