Back to Developer Portal
Integration Guide

Connecting to Hoberg ID

Learn how to authenticate users with Single Sign-On and retrieve scoped profile data in 3 simple steps.

1

Redirect to /oauth/authorize

When a user clicks "Continue with Hoberg" on your website, send them to our OAuth authorization endpoint with your registered client_id, redirect_uri, and desired scope.

GET https://id.hoberg.com.ng/oauth/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_CALLBACK&response_type=code&scope=profile:basic%20profile:education
2

Exchange Auth Code for Access Token

Hoberg ID will redirect the user back to your callback URL with an authorization code. Make a server-to-server POST request to exchange it for a cryptographically signed JWT.

POST https://id.hoberg.com.ng/api/oauth/token
3

Query Scoped Profile & Autofill

Use the Bearer token to query the central profile API. You will receive the user's immutable id (UUID) plus the permitted fields (school, CV, skills).

GET https://id.hoberg.com.ng/api/v1/profile (Header: Authorization: Bearer <token>)

TypeScript / Next.js Implementation Example

hoberg-auth.ts
// 1. Redirect user to Hoberg ID for authentication
export function loginWithHoberg() {
  const params = new URLSearchParams({
    client_id: 'hoberg_edu_live_app',
    redirect_uri: 'https://edu.hoberg.com.ng/auth/callback',
    response_type: 'code',
    scope: 'profile:basic profile:email profile:education profile:cv',
    state: 'random_secure_state_string',
  });

  window.location.href = `https://id.hoberg.com.ng/oauth/authorize?${params.toString()}`;
}

// 2. Exchange authorization code for scoped Access Token (Server-side)
export async function handleHobergCallback(code: string) {
  const tokenResponse = await fetch('https://id.hoberg.com.ng/api/oauth/token', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      grant_type: 'authorization_code',
      code,
      client_id: process.env.HOBERG_CLIENT_ID,
      client_secret: process.env.HOBERG_CLIENT_SECRET,
      redirect_uri: 'https://edu.hoberg.com.ng/auth/callback',
    }),
  });

  const { access_token, id_token } = await tokenResponse.json();

  // 3. Fetch authorized profile data
  const profileResponse = await fetch('https://id.hoberg.com.ng/api/v1/profile', {
    headers: {
      Authorization: `Bearer ${access_token}`,
    },
  });

  const user = await profileResponse.json();
  console.log('Authenticated Hoberg User UUID:', user.id);
  console.log('School & Course:', user.education);
  return user;
}

cURL / Raw HTTP Example

terminal.sh
# 1. Exchange Auth Code for Access Token
curl -X POST https://id.hoberg.com.ng/api/oauth/token \
  -H "Content-Type: application/json" \
  -d '{
    "grant_type": "authorization_code",
    "code": "hbg_auth_98127391823791283",
    "client_id": "hoberg_jobs_live_app",
    "client_secret": "your_client_secret_here",
    "redirect_uri": "https://jobs.hoberg.com.ng/auth/callback"
  }'

# 2. Query Scoped Profile Data
curl https://id.hoberg.com.ng/api/v1/profile \
  -H "Authorization: Bearer <access_token>"