Skip to main content

Connected accounts

The list of outside services that an agent can use for a person, with connect and disconnect for each.

PatternReadyView source
Works with
Reactshadcn/ui
Runs on sample data, with the neutral theme of shadcn/ui.

The place where a person decides which of their accounts an agent may use. The agent never sees the credentials: it asks LumoAuth for a token when it needs one.

Installation​

The command adds the file to your project, with the shadcn/ui components that it uses. Your project needs shadcn/ui.

pnpm dlx shadcn@latest add https://examples.lumoauth.dev/r/connections.json

Usage​

fromAgentConnection maps a row of the connections list. Whether the person linked the account is a fact of your own app, so set linked yourself.

app/settings/connections.tsx
'use client';

import { Connections, fromAgentConnection } from '@/components/connections';

export function ConnectedAccounts({ rows, linkedIds, accountUrl }: {
rows: Array<Record<string, unknown>>;
linkedIds: string[];
accountUrl: string; // the connections page of your LumoAuth organization
}) {
const connections = rows.map(fromAgentConnection).map((c) => ({ ...c, linked: linkedIds.includes(c.id) }));
// A person links and unlinks an account on the hosted account pages.
const open = () => window.location.assign(accountUrl);
return <Connections connections={connections} onLink={open} onUnlink={open} />;
}

LumoAuth runs the consent of each outside service on its hosted page "Accounts agents can use" (/account/connections). Send the person there for both actions. The account pages entry shows that page.

Where the data comes from​

What the pattern showsCall
The connections that an agent can useGET /agents/me/connections: connection_id, name, provider, provider_label, scopes
A token for one connection and one personPOST /agents/me/connections/{connection_id}/token with user_id
Link and unlink an accountThe hosted page /account/connections

States​

Runs on sample data, with the neutral theme of shadcn/ui.
  • The service asks for consent again.
  • Nothing to connect. The organization set up no service.

Props​

PropTypeDescription
connectionsrequiredConnectionData[]The connections to show.
onLink(id: string) => void | Promise<void>Called for Connect and for Reconnect.
onUnlink(id: string) => void | Promise<void>Called for Disconnect.
classNamestringClass name for the list.

ConnectionData​

OptionTypeDescription
idrequiredstringThe connection ID.
namerequiredstringThe name of the connection.
providerrequiredstringThe key of the service, for example github.
providerLabelstringThe name of the service to show.
scopesstring[]What agents will be able to use.
linkedbooleanTrue when the person linked their account.
accountstring | nullThe linked account.
needsConsentbooleanTrue when the service asks the person to give consent again.
agentsstring[]The agents that may use this connection.