Skip to content

Add OAuth sample for Figma plugins - #196

Open
asimawdah wants to merge 1 commit into
figma:mainfrom
asimawdah:feat/oauth-plugin-sample
Open

asimawdah wants to merge 1 commit into
figma:mainfrom
asimawdah:feat/oauth-plugin-sample

Conversation

@asimawdah

Copy link
Copy Markdown

What kind of change does this PR introduce?

Feature sample and documentation update.

What is the current behavior?

The sample repository does not include an OAuth example for plugins. Developers need to work out the server-mediated flow, the read/write key exchange, safe message passing, and local token persistence themselves.

Closes #125.

What is the new behavior?

  • Adds an OAuth plugin sample with a Figma main entry point, a UI redirect, and a plugin manifest.
  • Adds a self-hosted Node.js/Express server that creates separate one-time read and write keys, sets an HTTP-only SameSite cookie during top-level navigation, validates the returned OAuth state, and exchanges authorization codes using PKCE by default.
  • Restricts polling to the server origin, expires pending sessions, returns each result once, and avoids logging or persisting access tokens on disk.
  • Validates the UI message origin and restricts token delivery to Figma's origin and the configured plugin ID.
  • Stores the access token using figma.clientStorage.
  • Adds setup instructions, an environment template, and unit tests for opaque keys, PKCE, and timing-safe comparisons.
  • Adds the sample to the repository README.

How was this tested?

  • node --test — 3 security helper tests passed.
  • The TypeScript sample is configured for the repository's existing Figma typings and can be checked with npx tsc -p oauth/tsconfig.json after installing the repository dependencies.
  • The full OAuth flow still needs to be tested with a real OAuth provider and a publicly reachable HTTPS deployment, in both Figma Desktop and the browser.

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.

OAuth example

1 participant