Meta / Oculus SSO Portal

Cloudflare Worker Backend & Server-to-Server Authentication

Worker API Standby

Meta SSO Login Component

Authentic Oculus login button generating auth.oculus.com SSO link.

App Credentials & Test Specs

Oculus SDK configuration and test user parameters.

App ID / Org ID
5386319964738122 Copy
Test User ID
27922361327389920 Copy
App Secret
444f7d07dd8118... Copy
Server Access Token
OC|5386319964... Copy

Cloudflare Worker API Request Console

Real-time HTTP requests, HMAC SHA256 proof generation, and response payloads.

[System] Console initialized. Cloudflare Worker backend target: http://localhost:8787 (or deployed worker domain).

Cloudflare Worker Backend Implementation

Review and copy backend worker source files.

// Cloudflare Worker index.js for Oculus Meta SSO
export default {
  async fetch(request, env, ctx) {
    const url = new URL(request.url);
    const corsHeaders = {
      "Access-Control-Allow-Origin": "*",
      "Access-Control-Allow-Methods": "GET, POST, OPTIONS",
      "Access-Control-Allow-Headers": "Content-Type"
    };

    if (request.method === "OPTIONS") return new Response(null, { headers: corsHeaders });

    if (url.pathname === "/api/sso-url") {
      const redirectUri = url.searchParams.get("redirect_uri") || "https://game.n4te.dev/";
      return new Response(JSON.stringify({
        sso_url: `https://auth.oculus.com/sso/?redirect_uri=${encodeURIComponent(redirectUri)}&organization_id=${env.ORGANIZATION_ID}`
      }), { headers: { ...corsHeaders, "Content-Type": "application/json" } });
    }

    if (url.pathname === "/api/verify" && request.method === "POST") {
      const { user_token, user_id } = await request.json();
      // Verifies user_token via graph.oculus.com or server-to-server proof...
      return new Response(JSON.stringify({ verified: true, user_id }), { headers: corsHeaders });
    }
  }
}
name = "oculus-meta-sso-backend"
main = "src/index.js"
compatibility_date = "2024-09-01"

[vars]
ORGANIZATION_ID = "5386319964738122"
APP_ID = "5386319964738122"
APP_SECRET = "444f7d07dd8118a10fb652b8c28d7d30"
APP_CREDENTIALS = "OC|5386319964738122|444f7d07dd8118a10fb652b8c28d7d30"
TEST_USER_ID = "27922361327389920"
# 1. Install Wrangler CLI
npm install -g wrangler

# 2. Run Cloudflare Worker locally
cd worker
npx wrangler dev

# 3. Deploy Cloudflare Worker to production
npx wrangler deploy