Action that handles OAuth 2.0 authentication flows

Example

// Authorization Code flow - Step 1: Get auth URL
const authResult = await runAction({
ActionName: 'OAuth Flow',
Params: [{
Name: 'Operation',
Value: 'GetAuthorizationURL'
}, {
Name: 'Provider',
Value: 'github'
}, {
Name: 'ClientID',
Value: 'your-client-id'
}, {
Name: 'RedirectURI',
Value: 'http://localhost:3000/callback'
}, {
Name: 'Scopes',
Value: ['user', 'repo']
}]
});

// Step 2: Exchange code for token
const tokenResult = await runAction({
ActionName: 'OAuth Flow',
Params: [{
Name: 'Operation',
Value: 'ExchangeCodeForToken'
}, {
Name: 'Provider',
Value: 'github'
}, {
Name: 'ClientID',
Value: 'your-client-id'
}, {
Name: 'ClientSecret',
Value: 'your-client-secret'
}, {
Name: 'Code',
Value: 'auth-code-from-callback'
}, {
Name: 'RedirectURI',
Value: 'http://localhost:3000/callback'
}]
});

// Client Credentials flow
const tokenResult = await runAction({
ActionName: 'OAuth Flow',
Params: [{
Name: 'Operation',
Value: 'ClientCredentials'
}, {
Name: 'Provider',
Value: 'custom'
}, {
Name: 'TokenEndpoint',
Value: 'https://api.example.com/oauth/token'
}, {
Name: 'ClientID',
Value: 'your-client-id'
}, {
Name: 'ClientSecret',
Value: 'your-client-secret'
}]
});

Hierarchy (view full)

Constructors

Properties

providers: Record<string, any> = ...

Methods

  • Handles OAuth 2.0 authentication flows

    Parameters

    • params: RunActionParams<any>

      The action parameters containing:

      • Operation: "GetAuthorizationURL" | "ExchangeCodeForToken" | "RefreshToken" | "ClientCredentials" (required)
      • Provider: Provider name or "custom" (required)
      • ClientID: OAuth client ID (required)
      • ClientSecret: OAuth client secret (required for token operations)
      • RedirectURI: Callback URL (required for auth code flow)
      • Scopes: Array of scopes (optional)
      • State: State parameter for CSRF protection (optional, auto-generated if not provided)
      • Code: Authorization code (for ExchangeCodeForToken)
      • RefreshToken: Refresh token (for RefreshToken operation)
      • AuthorizationEndpoint: Custom auth endpoint (for custom provider)
      • TokenEndpoint: Custom token endpoint (for custom provider)
      • ScopeSeparator: Custom scope separator (default: space)

    Returns Promise<ActionResultSimple>

    OAuth flow result (authorization URL or tokens)

  • Executes the action with the provided parameters.

    Parameters

    • params: RunActionParams<any>

      The action execution parameters including context

    Returns Promise<ActionResultSimple>

    Promise resolving to the action result