Skip to content

OAuth Flow

This section documents the authentication and authorization flow used to connect an Organization (e.g., a delivery platform, POS system, or restaurant management system) to the Platform and allow secure access to data via MCP.

Participants

Participant Description
User Person who operates the platform and connects the organization
Platform Agent / UI that consumes data via MCP
Login (Organization) Login page of the restaurant software
OAuth (Organization) Organization's authorization server
MCP MCP server that exposes the tools (hosted by the organization or a delegated operator)
DataBridge Data access layer (runs the queries)

Organization

"Organization" represents any company integrated with the ecosystem. In this flow, the organization acts as a provider, exposing identity (OAuth / userinfo / merchants) and data. DataBridge is the generic data access layer behind an MCP — the organization or a delegated operator may run it. See Who operates the MCP.

How the platform obtains OAuth before the flow

Before the authorization flow, the platform needs to discover the authorization server endpoints and the client credentials. There are three scenarios:

  • No discovery metadata → manual configuration: the organization provides the endpoints and credentials (client_id/client_secret) explicitly.
  • With metadata + DCR → automatic flow: the platform reads the metadata (RFC 8414) and self-registers as a client (RFC 7591). Nothing is exchanged manually.
  • With metadata, without DCR → automatic endpoint discovery, but the credentials (client_id/client_secret) are provided manually.

Info

The authorization server requirements are the same in all scenarios. See OAuth Requirements for the full breakdown.

Interactive sequence diagram

Open fullscreen ↗

Flow steps

1. Organization connection

  1. User → Platform: clicks "Connect Organization".
  2. Platform → Login: redirects the user sending client_id, scopes and the PKCE flow parameters.
  3. User → Login: enters credentials (email/password) and performs MFA if necessary.
  4. Login → OAuth: validates the provided credentials.
  5. OAuth → Platform: returns an authorization code via callback.
  6. Platform → OAuth: exchanges the authorization code for tokens using the PKCE code_verifier.
  7. OAuth → Platform: returns access_token (JWT) and refresh_token.
  8. Platform: stores the connection tokens with the organization.
  9. Platform → OAuth: calls GET /merchants with the Bearer (preferred path for store scope).
  10. OAuth → Platform: returns the merchant list (rich catalog).
  11. Platform: builds the store picker / bind and the account business profile.
  12. Platform → User: informs that the organization was connected.

Note

The platform does not need to call userinfo in this step. Userinfo is consumed by the MCP on tool calls. See Userinfo and Merchants.

2. Query about organization data

  1. User → Platform: sends a prompt involving organization data.
  2. Platform → MCP: runs a tool — in the example, list_merchants (fallback for rediscovery/refresh; connect stores already came from /merchants) — with Bearer JWT.
  3. MCP: validates the JWT (signature, iss, aud, exp).
  4. MCP → OAuth (Organization): calls GET /userinfo with the Bearer token to obtain the user's authorization context (identity + permissions).
  5. OAuth (Organization) → MCP: returns sub, email and profile_permissions.
  6. MCP: applies the authorization logic — determines which merchants/resources the user can access.
  7. MCP → Platform: returns the tool result (e.g. authorized merchant list).

Note

The platform does not receive the raw userinfo payload. The MCP applies userinfo and returns only the tool result.

3. Data query

  1. Platform → MCP: runs tool_call fetch_data(merchant_ids) with Bearer JWT.
  2. MCP: validates the JWT (signature, iss, aud, exp) and checks the user's authorization scope (via userinfo / known scope).
  3. MCP → DataBridge: runs the necessary queries against the organization's data store, filtered by the authorized merchant_ids.
  4. DataBridge → MCP: returns the requested data.
  5. MCP → Platform: returns the result of the tool execution.
  6. Platform → User: displays the response with the merchant data.

References