auth.connect
authGET /auth/connectStarts the connection. The platform opens this route in a popup when a user clicks your integration. You decide what the user sees next: send them to the vendor's OAuth page, or show them a form.
For OAuth, build the authorization URL with your redirect set to ${BASE_URL}/auth/callback and the state set to `${connectionId}.${application}`. For API-key tools, return HTML with a form that ends up at /auth/callback carrying the key and the same state.
Arguments
applicationstringWhich of your applications the user is connecting. A provider with one application still receives it - guard against names you do not serve.
connectionIdstringThe platform's ID for this connection attempt. Thread it through state so your callback can return it.
Returns
AuthConnectResult - either { type: 'redirect', url } or { type: 'html', html }. The SDK issues the redirect or serves the HTML for you.
A key too big for a URL? Some credentials - a private key, a long PEM - do not fit in a query string. The pattern: your form POSTs the secret to a custom route you add on the app, that route stores it briefly and returns a short token, and only the token travels through /auth/callback. The Snowflake provider works this way.
async connect(logger, application, connectionId) {
if (application !== 'calls') {
throw new Error('Unsupported application');
}
return {
type: 'redirect',
url: client.buildAuthorizationUrl(oauthConfig, {
redirect_uri: `${process.env.BASE_URL}/auth/callback`,
state: `${connectionId}.${application}`,
code_challenge: await pkceChallenge(),
code_challenge_method: 'S256',
}).toString(),
};
}async connect(logger, application, connectionId) {
return {
type: 'html',
html: renderKeyForm({
// the form submits to /auth/callback with
// ?apiKey=...&state=connectionId.application
action: '/auth/callback',
state: `${connectionId}.${application}`,
}),
};
}