Skip to main content
Piece authentication is used to gather user credentials and securely store them for future use in different flows. The authentication must be defined as the auth parameter in the createPiece, createTrigger, and createAction functions. This requirement ensures that the type of authentication can be inferred correctly in triggers and actions.
The auth parameter for createPiece, createTrigger, and createAction functions can take an array, but you cannot have more than one auth property of the same type, i.e two OAUTH2 properties.

Secret Text

This authentication collects sensitive information, such as passwords or API keys. It is displayed as a masked input field. Example:

Username and Password

This authentication collects a username and password as separate fields. Example:

Custom

This authentication allows for custom authentication by collecting specific properties, such as a base URL and access token. Example:

Token Refresh (Server-Side Caching)

Some APIs require a login call to exchange credentials for a short-lived token. Without caching, this login happens before every action and can trigger 429 rate limit errors from the third-party API. Add an optional refresh callback to have Activepieces fetch the token once, cache it server-side, and inject it into every action/trigger as context.auth.access_token. The token is automatically renewed up to 15 minutes before it expires (clamped to half the token lifetime for short-lived tokens). Example:
Inside actions and triggers, read the cached token from context.auth.access_token:
refresh is opt-in. Pieces that don’t define it are unaffected. The generate callback receives the same flat auth object as validate (i.e. auth.baseUrl, auth.username), not the connection value wrapper.

OAuth2

This authentication collects OAuth2 authentication details, including the authentication URL, token URL, and scope. Example:
Please note OAuth2GrantType.CLIENT_CREDENTIALS is also supported for service-based authentication.