openai-browser-flow

Experimental browser-based OAuth flow for OpenAI usage in Node and n8n.

Package Information

Released: 4 mo ago
Downloads: 11 weekly / 80 monthly
Latest Version: 0.1.9

Documentation

n8n-nodes-openai-browser-flow

Experimental Node/TypeScript community node package for n8n, with a companion local auth bridge for testing an OpenAI browser login flow and then calling the Responses API with the returned bearer token.

This package is intended for local experiments and custom n8n integrations. It now includes an actual n8n node, but it still does not guarantee that OpenAI browser login tokens are valid for https://api.openai.com/v1/responses.

What it does

  • uses the n8n OAuth2 connect button against a local auth bridge
  • lets the local bridge do the real Authorization Code + PKCE flow with OpenAI
  • sends POST /v1/responses with Authorization: Bearer <token>
  • exposes an n8n node named OpenAI Browser Flow

Install

npm install n8n-nodes-openai-browser-flow

Basic usage

import { OpenAIBrowserFlowClient } from 'n8n-nodes-openai-browser-flow';

const client = new OpenAIBrowserFlowClient({
  clientId: 'YOUR_CLIENT_ID',
  clientSecret: 'OPTIONAL_CLIENT_SECRET',
  authorizationEndpoint: 'https://auth.openai.com/authorize',
  tokenEndpoint: 'https://auth0.openai.com/oauth/token',
  scopes: ['openid', 'profile', 'offline_access'],
  audience: 'https://api.openai.com',
  redirectHost: '127.0.0.1',
  redirectPort: 3456,
  redirectPath: '/callback',
});

await client.authenticate();

const response = await client.createResponse({
  model: 'gpt-4.1-mini',
  input: 'Diga oi em portugues.',
});

console.log(response.outputText);

n8n usage

After installing the package as a community node, n8n should load:

  • a credential type named OpenAI Browser Flow API
  • a node named OpenAI Browser Flow

The node exposes two operations:

  • Create Response: calls the OpenAI Responses API

The credential uses the standard n8n OAuth2 connection flow, but it is expected to point to a local bridge server instead of OpenAI directly.

Local bridge

A companion Flask bridge is expected at:

  • /home/gabrieldossantospeixoto/Documentos/GitHub/PESSOAL/openai-auth-bridge

Run that bridge first, then configure the credential with:

  • Authorization URL: http://localhost:1455/oauth/authorize
  • Access Token URL: http://localhost:1455/oauth/token
  • App ID: your OpenAI app_... id
  • Client Secret: hidden and empty by default

The bridge completes the real OpenAI login on http://localhost:1455/openai/callback and hands the resulting token payload back to n8n.

The reusable library can also be used by:

  • an internal helper package used by a node
  • a Code node, if the runtime allows loading external packages

Important limitations

  • browser/OAuth support for OpenAI API access is not validated by this package
  • the returned token may be valid only for identity, not for v1/responses
  • OpenAI may require a different audience, scope, redirect, or app registration flow
  • this package now expects the OAuth connection to be completed through the n8n credential UI backed by the local Flask bridge

API

new OpenAIBrowserFlowClient(config)

Config fields:

  • clientId: OAuth client id
  • clientSecret: optional client secret
  • authorizationEndpoint: defaults to https://auth.openai.com/authorize
  • tokenEndpoint: defaults to https://auth0.openai.com/oauth/token
  • scopes: defaults to openid profile offline_access
  • audience: optional audience
  • redirectHost: defaults to 127.0.0.1
  • redirectPort: defaults to 3456
  • redirectPath: defaults to /callback
  • openBrowser: defaults to true
  • callbackTimeoutMs: defaults to 5 minutes
  • apiBaseUrl: defaults to https://api.openai.com/v1

Methods:

  • authenticate()
  • setAccessToken(accessToken)
  • createResponse(request)

Bridge repository

The local bridge repository lives at:

  • /home/gabrieldossantospeixoto/Documentos/GitHub/PESSOAL/openai-auth-bridge

Discussion