Overview
Flow OAuth Client Authentication allows you to create secure OAuth 2.0 credentials that can be used to authenticate API requests to your Chain.io flows. This feature is ideal for:
- Issuing credentials to third-party trading partners
- Authenticating automated systems and integrations
- Providing secure, token-based access to your flows
- Managing multiple API clients with individual credentials
OAuth clients use the industry-standard OAuth 2.0 Client Credentials flow, where a Client ID and Client Secret are exchanged for a short-lived JWT (JSON Web Token) that can be used to authenticate flow submissions.
Creating an OAuth Client
Step 1: Navigate to OAuth Clients
- Go to Workspace Settings in your Chain.io portal
- Select Flow OAuth Clients from the
- Click the Create New Client button
Step 2: Configure Client Details
You will need to provide three pieces of information:
Client Name (Required)
- A human-readable description of the client
- Example: "Partner ABC Production API" or "Internal ERP System"
- This helps you identify the purpose of each client
Client ID (Required)
- Always starts with your company's 4-character short code (automatically prefixed)
- Followed by a hyphen
- - Then 5-10 alphanumeric characters of your choice
- Example: If your company code is
abcd, your Client ID might beabcd-PRODAPI - Note: The company prefix cannot be changed
Activation Email Address (Required)
- Email address where the activation link will be sent
- Can be your own email or a third-party recipient's email
- The recipient will receive the Client Secret directly upon activation
- This ensures the secret goes directly to the person who will use it
- Tip: If you are creating one for your own use, you can use your own email address
Step 3: Create the Client
- Click Create to generate the OAuth client
- The client will be created in Pending Activation status
- An activation email will be sent to the specified address
- The recipient has 24 hours to activate the client before the link expires
Activating an OAuth Client
Activation Process
- Check the email inbox for the activation email
- Click the Activate Client link in the email
- You will be taken to the Chain.io activation page
- No Chain.io account is required to activate a client
- Review the Client ID displayed on the page
- Click the Activate Client button
Retrieving Your Credentials
Once activated, you will see:
- Client ID - Copy this using the copy button
- Client Secret - Copy this using the copy button
⚠️ IMPORTANT: This is the ONLY time you will be able to view the Client Secret.
- Make sure to copy and store both the Client ID and Client Secret securely
- If you lose the Client Secret, you will need to create a new OAuth client
- The activation page provides instructions on how to use these credentials
Security Best Practices
- Store credentials in a secure password manager or secrets vault
- Never commit credentials to source control or share them in plain text
- Do not expose the Client Secret in client-side code or public repositories
- If you suspect credentials have been compromised, immediately revoke the client and create a new one
Using OAuth Clients in Your Flows
Configuring a Flow to Accept OAuth Authentication
- Navigate to your trading partner or create a new integration
- Create a new flow or edit an existing one
- When configuring your Source Connection, select API as the connection type
- In the Authentication section, you will now see OAuth Client as an option
- Select OAuth Client from the authentication dropdown
- Choose the OAuth client you created from the dropdown list
- Complete the rest of your flow configuration as normal (destination, mappings, etc.)
- Save and Deploy your flow
Once deployed, the flow will only accept requests authenticated with a valid JWT token obtained using the selected OAuth client credentials.
Exchanging Credentials for a JWT Token
Before you can submit data to your OAuth-protected flow, you must exchange your Client ID and Client Secret for a JWT access token.
Token Exchange Endpoint
POST https://webhooks.chain.io/oauth/token
Request Format
Headers:
Content-Type: application/x-www-form-urlencoded
Body Parameters:
grant_type=client_credentials
client_id=YOUR_CLIENT_ID
client_secret=YOUR_CLIENT_SECRET
Example: cURL
curl -X POST https://webhooks.chain.io/oauth/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=abcd-PRODAPI" \
-d "client_secret=your-client-secret-here"
Example: Postman
- Create a new POST request to
https://webhooks.chain.io/oauth/token - Set the body type to
x-www-form-urlencoded - Add three key-value pairs:
-
grant_type:client_credentials -
client_id: Your Client ID -
client_secret: Your Client Secret
-
- Send the request
Response
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "Bearer",
"expires_in": 900
}
Response Fields:
-
access_token- The JWT token to use for authentication -
token_type- Always "Bearer" -
expires_in- Token lifetime in seconds (15 minutes / 900 seconds)
⚠️ Note: JWT tokens expire after 15 minutes. Request a new token when needed.
Submitting Data to Your Flow
Once you have obtained a JWT token, you can use it to submit data to your OAuth-protected flow.
Request Format
Method: POST (or as configured in your flow)
URL: Your flow's webhook URL
Headers:
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json (or other types depending on file format)
Body: Your JSON payload (as defined by your flow)
Example: cURL
curl -X POST https://webhooks.chain.io/YOUR_FLOW_ENDPOINT \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
-H "Content-Type: application/json" \
-d '{
"your": "data",
"goes": "here"
}'
Example: Postman
- Create a new POST request to your flow's endpoint URL
- Go to the Authorization tab
- Type:
Bearer Token - Token: Paste your JWT access token
- Type:
- Go to the Body tab
- Select
rawandJSON - Enter your JSON payload
- Select
- Send the request
Success Response
If authentication and submission are successful, you will receive a response from your flow (typically a 200 status code). You can view the flow execution in your Chain.io portal under the trading partner's flow execution history.
Managing OAuth Clients
Viewing Active Clients
- Navigate to Workspace Settings → Flow OAuth Clients
- You will see a list of all OAuth clients with their status:
- Active - Client has been activated and can be used
- Pending Activation - Client created but not yet activated
- Revoked - Client has been disabled
Revoking a Client
If you need to disable an OAuth client:
- Go to Workspace Settings → Flow OAuth Clients
- Find the client you want to revoke
- Click the Revoke button
- Confirm the revocation
⚠️ Note: Revoked clients cannot be reactivated. Any flows configured to use a revoked client will reject authentication attempts. You will need to create a new client if needed and redploy the flows.
Activation Expiration
- Activation links expire 24 hours after creation
- If the link expires before activation, you will need to create a new OAuth client
- There is no way to resend an expired activation link
Rotating Client Secrets
If you need to change your Client Secret without creating a new client (e.g., for security compliance or after potential credential exposure), you can rotate the secret using the API.
Important: This is an advanced operation. The old secret will be immediately invalidated upon successful rotation.
Rotation Endpoint
POST https://webhooks.chain.io/oauth/rotate-secret
Request Format
Headers:
Content-Type: application/x-www-form-urlencoded
Body Parameters:
client_id=YOUR_CLIENT_ID
client_secret=YOUR_CURRENT_CLIENT_SECRET
Example: cURL
curl -X POST https://webhooks.chain.io/oauth/rotate-secret \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "client_id=abcd-PRODAPI" \
-d "client_secret=your-current-secret-here"
Example: Postman
- Create a new POST request to
https://webhooks.chain.io/oauth/rotate-secret - Set the body type to
x-www-form-urlencoded - Add two key-value pairs:
-
client_id: Your Client ID -
client_secret: Your current Client Secret
-
- Send the request
Response
{
"client_secret": "7ab69c78-9abf-48e6-a16e-ae528abdbb548e79609559274bce97467facd508b66d"
}
Response Fields:
-
client_secret- Your new Client Secret
⚠️ CRITICAL: The old secret is immediately invalidated when you rotate.
Best Practices for Secret Rotation
Before Rotation:
- Plan the rotation during a maintenance window if possible
- Notify any teams or partners using the client
- Have a rollback plan in case of issues
During Rotation:
- Call the rotation endpoint and securely store the new secret
- Update all systems using the old secret with the new secret
- Test authentication with the new secret before fully deploying
After Rotation:
- Verify all systems are using the new secret successfully
- Monitor for any authentication failures
- Update your documentation and password manager with the new secret
When to Rotate:
- Security compliance requirements (e.g., every 90 days)
- Suspected credential compromise or exposure
- Offboarding a team member who had access to the secret
- After a security audit or penetration test
- As part of regular security hygiene
Important Notes:
- The rotation is instantaneous - there is no grace period where both secrets work
- Any in-flight JWT tokens obtained with the old secret remain valid until they expire (15 minutes)
- If rotation fails, your current secret remains valid
- You must have the current valid secret to perform rotation (you cannot rotate if you've lost the secret)
Common Use Cases
Scenario 1: Issuing Credentials to a Trading Partner
- Create an OAuth client with the partner's name in the Client Name field
- Use the partner's email address as the Activation Email
- The partner receives the activation email directly
- They activate and receive the credentials
- They use the credentials to authenticate their system's API calls to your flow
Benefits: The secret never passes through your organization's email, increasing security.
Scenario 2: Authenticating Your Own Internal System
- Create an OAuth client for your system (e.g., "ERP Production")
- Use your own email address
- Activate and retrieve the credentials
- Store the credentials in your application's secure configuration
- Implement token exchange logic in your application code
- Use the JWT to authenticate flow submissions
Scenario 3: Multiple Environments
Create separate OAuth clients for different environments:
-
abcd-DEVfor development -
abcd-TESTfor testing -
abcd-PRODfor production
This allows you to track usage separately and revoke environment-specific credentials if needed.
Troubleshooting
"Invalid activation link" Error
Cause: The activation link has expired (> 24 hours) or has already been used.
Solution: Create a new OAuth client.
"Client already activated" Error
Cause: You are trying to activate a client that has already been activated.
Solution: The client is ready to use. If you lost the credentials, you must create a new client.
"Invalid client credentials" Error (Token Exchange)
Cause: The Client ID or Client Secret is incorrect.
Solution:
- Verify you copied the credentials correctly
- Ensure there are no extra spaces or characters
- If you lost the secret, create a new OAuth client
"Token expired" Error (Flow Submission)
Cause: The JWT token has expired (> 15 minutes old).
Solution: Request a new JWT token from the token exchange endpoint.
"Unauthorized" Error (Flow Submission)
Possible Causes:
- JWT token is invalid or expired
- The flow is not configured to accept the OAuth client you're using
- The OAuth client has been revoked
Solution:
- Request a fresh JWT token
- Verify the flow's source connection is configured to use your OAuth client
- Check that the client is still active in Workspace Settings
Flow Not Receiving Data
Checklist:
- Verify the flow is deployed (not in draft state)
- Confirm you're using the correct flow endpoint URL
- Ensure the Authorization header is properly formatted:
Bearer YOUR_TOKEN - Check that your JSON payload matches the flow's expected input format
- Review the flow execution history for error details
Secret Rotation Failed
Cause: Invalid credentials provided to the rotation endpoint or client has been revoked.
Solution:
- Verify you're using the correct current Client ID and Secret
- Ensure the client is still active (not revoked) in Workspace Settings
- Check for typos or extra spaces in your credentials
- If you've lost the current secret, you cannot rotate - create a new OAuth client instead
Authentication Works But Suddenly Stops
Cause: The Client Secret may have been rotated by someone else.
Solution:
- Contact your team to see if anyone rotated the secret
- If rotation occurred, obtain the new secret and update your configuration
- If the client was revoked, create a new client
Security Considerations
Token Lifetime
- JWT tokens expire after 15 minutes for security
- Implement token refresh logic in your application
- Request a new token before the current one expires
Credential Storage
- DO NOT hardcode credentials in your application code
- Use environment variables or secure configuration management
- Consider using a secrets manager (e.g., AWS Secrets Manager, Azure Key Vault, HashiCorp Vault)
Access Control
- Create separate OAuth clients for different partners or systems
- Revoke clients immediately if credentials are compromised
- Regularly audit active OAuth clients and revoke unused ones
- Implement a secret rotation policy (e.g., rotate every 90 days for compliance)
- Use the rotation endpoint to update secrets without creating new clients
Monitoring
- Monitor flow execution logs for unusual activity
- Track failed authentication attempts
- Set up alerts for suspicious patterns
API Reference Summary
Token Exchange Endpoint
Endpoint: POST https://webhooks.chain.io/oauth/token
Request Body (x-www-form-urlencoded):
| Parameter | Required | Description |
|---|---|---|
grant_type |
Yes | Must be client_credentials
|
client_id |
Yes | Your OAuth Client ID |
client_secret |
Yes | Your OAuth Client Secret |
Success Response (200):
{
"access_token": "string",
"token_type": "Bearer",
"expires_in": 900
}
Error Responses:
-
400- Invalid request (missing parameters) -
401- Invalid client credentials -
500- Server error
Secret Rotation Endpoint
Endpoint: POST https://webhooks.chain.io/oauth/rotate-secret
Request Body (x-www-form-urlencoded):
| Parameter | Required | Description |
|---|---|---|
client_id |
Yes | Your OAuth Client ID |
client_secret |
Yes | Your current OAuth Client Secret |
Success Response (200):
{
"client_secret": "string"
}
Error Responses:
-
400- Invalid request (missing parameters) -
401- Invalid client credentials -
404- Client not found or already revoked -
500- Server error
⚠️ Note: Old secret is immediately invalidated upon successful rotation.
Flow Submission
Endpoint: POST https://webhooks.chain.io/{your-flow-endpoint}
Headers:
| Header | Required | Value |
|---|---|---|
Authorization |
Yes | Bearer {your-jwt-token} |
Content-Type |
Yes | application/json |
Body: JSON payload as defined by your flow configuration
Additional Resources
- OAuth 2.0 Specification: https://oauth.net/2/
- JWT Documentation: https://jwt.io
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article