High-level OAuth flow orchestration for Plaid Link.
Manages the complete OAuth flow for institutions that require out-of-app authorization (e.g., Chase, Wells Fargo, Capital One).
Flow overview
Desktop / web flow:
initiate/2— creates Link token with PKCE, stores state- User completes Link, is redirected to your
oauth_redirect_uri complete/2— validates state, exchanges public token
Example
{:ok, %{link_token: token, oauth_state: state}} =
PlaidEx.OAuth.Flow.initiate(config,
user_id: "user-123",
products: ["transactions"],
redirect_uri: "https://myapp.com/oauth/callback"
)
Summary
Types
@type initiate_result() :: %{ link_token: String.t(), expiration: String.t(), oauth_state: String.t(), pkce: PlaidEx.OAuth.PKCE.t() }
Functions
@spec complete( PlaidEx.Config.t(), keyword() ) :: {:ok, %{access_token: String.t(), item_id: String.t()}} | {:error, PlaidEx.Error.t()}
Completes an OAuth flow after the user is redirected back.
Validates state, retrieves PKCE verifier, and exchanges the public token for an access token.
@spec initiate(PlaidEx.Config.t(), initiate_opts()) :: {:ok, initiate_result()} | {:error, PlaidEx.Error.t()}
Initiates an OAuth Link flow.
Creates a Link token with PKCE challenge and stores OAuth state.