Credentials
Credentials are authentication tokens or API keys that Alloy Automation uses to communicate with third-party platforms on behalf of your users. Each credential is attached to a specific user and connector.Understanding Credentials
What Credentials Store
Credentials contain the authentication data required to access third-party platforms:- OAuth 2.0 tokens: Access tokens and refresh tokens for platforms like HubSpot, Salesforce, and Notion
- API keys: Static API keys and secrets for platforms like QuickBooks and Zendesk
- Custom authentication: Other authentication schemes as required by specific connectors
Credential Ownership
- Each credential belongs to a specific user
- A user can have multiple credentials for different connectors
- A user can have multiple credentials for the same connector (e.g., multiple HubSpot accounts)
- Alloy Automation stores and manages credentials securely with encryption at rest
Authentication Types
OAuth 2.0
Most modern SaaS platforms use OAuth 2.0. Alloy Automation handles the complete OAuth flow including automatic token refresh. Example platforms: HubSpot, Xero, Notion, and othersAPI Keys
Some platforms use API keys or custom authentication schemes. Example platforms: Zendesk, NetSuite and othersDiscovering Credential Requirements
Before creating credentials, discover what authentication data a connector requires:- Determine the authentication type (OAuth 2.0, API key, etc.)
- Identify required fields for credential creation
- Build dynamic credential collection forms
- Validate input before creating credentials
Creating OAuth 2.0 Credentials
Step 1: Initiate OAuth Flow
In our example above, we know Hubspot uses OAuth. Therefore, we’ll passoauth2
as the authenticationType
to the POST /credentials
endpoint to request an authorization URL:
Step 2: User Authenticates
- Redirect the user to the
oauthUrl
- User logs into the third-party platform (e.g., HubSpot)
- User grants permissions to your application
- Platform redirects back to your
redirectUri
with an authorization code
Step 3: Token Exchange
Alloy Automation automatically exchanges the authorization code for access and refresh tokens. The credential is created and attached to the user without additional API calls.Step 4: Save Credential ID
After the OAuth flow completes, you’ll receive acredentialId
. Store this ID in your database mapped to the user.
Creating API Key Credentials
In the example above, we looked at how to create credentials for apps using OAuth. For connectors that use API keys:Using Credentials
Once created, reference the credential when executing actions:Automatic Token Refresh
For OAuth 2.0 credentials, Alloy Automation automatically refreshes access tokens when they expire. You don’t need to handle token refresh logic in your application.Credential Lifecycle
When Credentials Become Invalid
Credentials can become invalid when:- User revokes access in the third-party platform
- OAuth tokens are manually revoked
- API keys are rotated or deleted in the third-party platform
Handling Invalid Credentials
When a credential is invalid, the API returns an error:Security
What You Store
You are responsible for securely storing:- Mapping between your users and Alloy Automation
userId
values - Mapping between users and their
credentialId
values
What Alloy Automation Stores
Alloy Automation securely stores:- OAuth access and refresh tokens (encrypted at rest)
- API keys and secrets (encrypted at rest)
- Credential metadata (connector type, creation date, etc.)
Important Security Note
Credential IDs (credentialId
) are safe to store in your database, but they are only usable with your API key. Always validate that a user owns a credential before allowing operations with that credential.
Testing with Sandbox Accounts
When testing credential flows, use sandbox or developer accounts:- HubSpot: Free developer account
- Salesforce: Developer sandbox
- Notion: Personal workspace
Next Steps
- Learn about Authentication layers
- Explore Executing Actions with credentials
- Review Users and credential ownership