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

664 B
Raw Blame
import { PieceAuth } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { makeReadwiseRequest } from './client';

export const readwiseAuth = PieceAuth.SecretText({
  displayName: 'Access Token',
  description:
    'Your Readwise access token. Get it at https://readwise.io/access_token',
  required: true,
  validate: async ({ auth }) => {
    try {
      await makeReadwiseRequest({
        token: auth,
        method: HttpMethod.GET,
        endpoint: '/auth/',
      });
      return { valid: true };
    } catch (e) {
      return { valid: false, error: 'Invalid Readwise access token.' };
    }
  },
});