API Docs

Documentation

Everything you need to integrate OAuth Hub into your application

Quick Start Guide

Get started with OAuth Hub in minutes. This guide will walk you through creating your first OAuth application.

1. Create an Application

Navigate to the Apps page and create a new OAuth application.

  • Enter your application name
  • Add your redirect URIs (callback URLs)
  • Select the scopes you need
  • Click "Create Application"

2. Get Your Credentials

After creating your app, you'll receive:

  • Client ID: Public identifier for your app
  • Client Secret: Keep this secure! Only shown once.

3. Implement OAuth Flow

Use the Authorization Code Flow with PKCE (recommended):

Step 1: Generate PKCE Challenge

// Generate code verifier
const codeVerifier = generateRandomString(64);

// Generate code challenge
const sha256 = await crypto.subtle.digest(
  'SHA-256',
  new TextEncoder().encode(codeVerifier)
);
const codeChallenge = base64UrlEncode(sha256);

Step 2: Redirect to Authorization URL

const authUrl = new URL('/api/v1/oauth/authorize', window.location.origin);
authUrl.searchParams.append('client_id', 'YOUR_CLIENT_ID');
authUrl.searchParams.append('redirect_uri', 'YOUR_REDIRECT_URI');
authUrl.searchParams.append('response_type', 'code');
authUrl.searchParams.append('scope', 'openid profile email');
authUrl.searchParams.append('code_challenge', codeChallenge);
authUrl.searchParams.append('code_challenge_method', 'S256');

window.location.href = authUrl.toString();

Step 3: Exchange Code for Token

const response = await fetch('/api/v1/oauth/token', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    grant_type: 'authorization_code',
    code: authorizationCode,
    redirect_uri: 'YOUR_REDIRECT_URI',
    client_id: 'YOUR_CLIENT_ID',
    client_secret: 'YOUR_CLIENT_SECRET',
    code_verifier: codeVerifier
  })
});

const { access_token, refresh_token } = await response.json();

4. Make API Calls

Use the access token to call protected endpoints:

const userInfo = await fetch('/api/v1/oauth/userinfo', {
  headers: {
    'Authorization': `Bearer ${access_token}`
  }
});

const user = await userInfo.json();
// { sub, email, name, ... }