Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

798 B
Raw Blame
import { AppConnectionValueForAuthProperty, PieceAuth } from '@activepieces/pieces-framework';
import { tryCatch } from '@activepieces/pieces-framework';
import { Client } from 'recurly';

export const recurlyAuth = PieceAuth.SecretText({
  displayName: 'API Key',
  description: `You can obtain API key from [Developer Settings](https://app.recurly.com/go/developer/api_keys).`,
  required: true,
  validate: async ({ auth }) => {
    const { error } = await tryCatch(() =>
      new Client(auth).listSites().first(),
    );

    if (error) {
      return {
        valid: false,
        error: 'Invalid API key. Check the API key and try again.',
      };
    }

    return {
      valid: true,
    };
  },
});

export type RecurlyAuthType = AppConnectionValueForAuthProperty<typeof recurlyAuth>