Overview
There are two ways of authenticating with automations: static bearer token (default) or OAuth 2.0 Client Credentials. For enhanced security, Factory customers may switch to OAuth 2.0 Client Credentials, a machine-to-machine authentication flow in which access tokens are issued by an external identity provider (e.g. Okta, Auth0, Keycloak) and presented to the Automation API. The API validates each token and authorizes requests based on its defined scopes.Authentication Flow
Setup
To enable this feature, you’ll need to configure your Identity Provider as follows. There are many ways you can configure this based on your Identity Provider. Here are two examples: Client Secret–based Client Authentication (most common) and Private Key JWT Client Authentication.Client Secret-based Client Authentication (most common)
Step 1: Create Authorization Server
Create an authorization server with audience set to CrewAI AOP URL (e.g.https://crewai.yourdomain.test).
If using Okta, follow: Okta Admin Console > Security > API > Add Authorization Server.
Step 2: Create Scope
Under your authorization server settings, create a scope namedcrewai_automations.
If using Okta, follow: Okta Admin Console > Security > API > Select your authorization server > Scopes > Add Scope.
Step 3: Create Access Policy (Okta)
If using Okta, create an access policy to ensure clients can use this authorization server: Okta Admin Console > Security > API > Select your authorization server > Access Policies > Add New Access Policy. Be sure to create at least one rule in your recently created access policy so clients can access it.Step 4: Enable in CrewAI AOP
On CrewAI AOP, go to Settings > Organization > Toggle OAuth 2.0 for Automations, and fill in your newly created authorization server information.Step 5: Request Access Token
Use your identity provider to issue a new access token with access to thecrewai_automations scope:
Step 6: Authenticate to Automation
Use the generated access token to authenticate to your automation:Private Key JWT Client Authentication
Step 1: Create App Integration
Create an app integration in Okta: Okta > Applications > Create App Integration > Select the API Services sign-in method > Give it a name > Save.Step 2: Configure Client Authentication
On the app integration’s General settings, go to Client Credentials > Client authentication > Select “Public key / Private key”. In that same section, choose “Save keys in Okta” > Add key > Generate new key. Store the private key securely in.pem format, then click Save.
Step 3: Create Authorization Server
Create an authorization server with audience set to CrewAI AOP URL (e.g.https://crewai.yourdomain.test).
If using Okta, follow: Okta Admin Console > Security > API > Add Authorization Server.
Step 4: Create Scope
Under your authorization server settings, create a scope namedcrewai_automations.
If using Okta, follow: Okta Admin Console > Security > API > Select your authorization server > Scopes > Add Scope.
Step 5: Create Access Policy (Okta)
If using Okta, create an access policy to ensure clients can use this authorization server: Okta Admin Console > Security > API > Select your authorization server > Access Policies > Add New Access Policy. Be sure to create at least one rule in your recently created access policy so clients can access it.Step 6: Enable in CrewAI AOP
On CrewAI AOP, go to Settings > Organization > Toggle OAuth 2.0 for Automations, and fill in your newly created authorization server information.Step 7: Generate Signed JWT
Generate a signed JWT using your private key. The following is a helper script example that demonstrates how to create the client assertion JWT required for authentication:Step 8: Generate Access Token
Use your identity provider to issue a new access token with access to thecrewai_automations scope, using the signed JWT from the last step:
