Tag
Blog: Reference
All blog posts tagged with Reference.

API Reference: Authentication Endpoints

Complete reference for authentication API endpoints with request/response formats and examples.

POST /auth/token

Exchange credentials for access token.

Request:

{
  "grant_type": "password",
  "username": "user@example.com",
  "password": "secure123",
  "scope": "openid profile email"
}

Response:

{
  "access_token": "eyJhbG...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "8xLOx...",
  "scope": "openid profile email"
}

POST /auth/refresh

Refresh access token using refresh token.

Headers:

Authorization: Bearer <refresh_token>

Response:

{
  "access_token": "eyJhbG...",
  "expires_in": 3600
}

See error codes section for detailed error responses.

JavaScript SDK Reference

Comprehensive reference for the JavaScript SDK with TypeScript support.

Installation

npm install @authcompany/js-sdk

Initialization

import { AuthClient } from '@authcompany/js-sdk';

const auth = new AuthClient({
  clientId: string;
  domain: string;
  redirectUri?: string;
  audience?: string;
  scope?: string;
});

Core Methods

loginWithRedirect()

Initiates login flow with redirect.

await auth.loginWithRedirect({
  appState?: any;
  loginHint?: string;
});

getUser()

Retrieves authenticated user profile.

const user = await auth.getUser();
// Returns: User | null

handleRedirectCallback()

Processes authentication callback.

const result = await auth.handleRedirectCallback();
// Returns: { appState?: any }

Events

auth.on('authenticated', (user) => {
  console.log('User logged in:', user);
});

For advanced usage and configuration, see our advanced guides.