Skip to content

feat(heygen): add HeyGen OAuth 2.0 emulator#42

Open
miguel-heygen wants to merge 1 commit intovercel-labs:mainfrom
miguel-heygen:feat/heygen-oauth-emulator
Open

feat(heygen): add HeyGen OAuth 2.0 emulator#42
miguel-heygen wants to merge 1 commit intovercel-labs:mainfrom
miguel-heygen:feat/heygen-oauth-emulator

Conversation

@miguel-heygen
Copy link
Copy Markdown

@miguel-heygen miguel-heygen commented Apr 2, 2026

Summary

Adds a new @emulators/heygen package implementing HeyGen's OAuth 2.0 authorization code flow with mandatory PKCE, matching HeyGen's production API shape.

Why HeyGen? HeyGen uses a custom OAuth2 server split across two hosts (app.heygen.com for authorize, api2.heygen.com for token/user endpoints) with a non-standard response wrapper ({ code: 100, data, message }) on the user endpoint. This emulator lets apps built on HeyGen auth test their full login flow locally without hitting production.

Routes

Method Path Description
GET /oauth/authorize User-picker UI
POST /oauth/authorize/callback Issues code and redirects
POST /v1/oauth/token Authorization code exchange with PKCE
POST /v1/oauth/refresh_token Refresh token grant (separate endpoint, matching production)
GET /v1/user/me User profile in HeyGen's { code, data, message } wrapper

Matches production behavior

  • PKCE-only — no client_secret required in token exchange (public client flow)
  • Separate refresh endpoint/v1/oauth/refresh_token, not the same as the token endpoint
  • /v1/user/me response wrapped in { code: 100, data: { user: { user_id, email, username } }, message: "Success" }
  • expires_in: 864000 (10 days) matching real HeyGen token lifetime
  • redirect_uri validation on token exchange per RFC 6749 §4.1.3

Verified working

Tested end-to-end with a Next.js app using PKCE: redirect to emulator → user-picker → callback → token exchange → refresh → /v1/user/me → authenticated session.

Changes

  • packages/@emulators/heygen/ — full OAuth2 + PKCE implementation
  • packages/emulate/src/registry.ts — service registration with initConfig defaults
  • skills/heygen/SKILL.md — agent skill docs
  • apps/web/app/heygen/ — docs page
  • README.md — port listing and auth notes
  • Navigation + page-titles updated

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 2, 2026

@miguel-heygen is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@miguel-heygen miguel-heygen force-pushed the feat/heygen-oauth-emulator branch 2 times, most recently from bd2efec to b8cd0c7 Compare April 2, 2026 11:12
Implements a full OAuth 2.0 authorization code flow with PKCE support
for local HeyGen auth testing, following the same pattern as the existing
Google and Microsoft providers.

Routes:
- GET /oauth/authorize: user-picker UI
- POST /oauth/authorize/callback: issues code and redirects
- POST /oauth/token: code exchange and refresh token grant with PKCE validation
- GET /oauth/userinfo: returns both OIDC-standard (sub, name, picture) and
  HeyGen-specific aliases (user_id, full_name, avatar_url)

Includes seed config support for users and OAuth clients, docs page,
skills file, README entry, and navigation updates.
@miguel-heygen miguel-heygen force-pushed the feat/heygen-oauth-emulator branch from b8cd0c7 to ec76d5c Compare April 2, 2026 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant