Adding Authentication to
an API
End PointCalls
Step 1 - Enable Authentication
- Open the Incoming API/API End Point Actionflow
- On the toolbar click
Insert excerpt |
---|
| _property_settings |
---|
| _property_settings |
---|
nopanel | true |
---|
|
- In the API section, disable
Insert excerpt |
---|
| _toggle_off |
---|
| _toggle_off |
---|
nopanel | true |
---|
|
Allow Anonymous Connection - This will then only allow authenticated calls to the API
- the changes
Step 2 - Create an Authentication User
- In the
Insert excerpt |
---|
| _repository |
---|
| _repository |
---|
nopanel | true |
---|
|
, expand the application with the Incoming API - Expand and create an New Role by clicking
Insert excerpt |
---|
| _addIcon |
---|
| _addIcon |
---|
nopanel | true |
---|
|
- Pin the tab as we will need it to remain open
- Provide a useful Name, e.g. GenerateToken
- In the Privileges section, click
Insert excerpt |
---|
| _privilege |
---|
| _privilege |
---|
nopanel | true |
---|
|
- Search for the privilege in the Full Repository :
Use API Key
- Drag the Use API Key into the Privileges section of the Role
Insert excerpt |
---|
| _property_settings |
---|
| _property_settings |
---|
nopanel | true |
---|
|

- the changes
- In the
Insert excerpt |
---|
| _user_group |
---|
| _user_group |
---|
nopanel | true |
---|
|
section, click Insert excerpt |
---|
| _user_group |
---|
| _user_group |
---|
nopanel | true |
---|
|
- Add a new Group for you your Role
- Give it a useful Name e.g. API Users
- Add any users you require to be able to run the API. This could be a dedicated API user with limited privileges
- To create a user see Managing User Accounts → Creating Users
- Click and close the tab
- Now drag the new user group into the
Insert excerpt |
---|
| _user_group |
---|
| _user_group |
---|
nopanel | true |
---|
|
section of the new privilegerole - the changes
- The setup should look similar to:

Step 3 - Authentication Token KeyStore
A signing key is used to generate the PhixFlow API key and this is stored on the server to ensure secure access.
Using the page Configure a Keystore and Aliases, configure phixflow-api-key to be used as the signing key for PhixFlow API Keys in the same way as the pepperKey is configured. This secret string must be a minimum of 32 bytes length.
Step 4 - Generate Authentication Token
- The Incoming API will run as a specified user, this means that when it is called the audit trail will show the specified user as having performed the Incoming API Actionflow
- You do not need to login as this user, however, if you were already logged in as this user, you will need to logout and login again to pick up the user group change
- In the
Insert excerpt |
---|
| _repository |
---|
| _repository |
---|
nopanel | true |
---|
|
, scroll down to the Full Repository section and expand it - Expand the section
- Double click on the user who will run the Incoming API
- Click the 3-dot more menu in the top right of the user properties
- Click Generate API Key
- Copy the value displayed and store it somewhere safe

Step 5 - Send Authorization
When calling the Incoming API, the authorisation token must be passed in as a header called: Authorization.
Worked Example
Here's a worked example using the Company Data (available from the Learning Centre).
In this example, we are using:
- A Company Orders screen containing two grids of the Orders and OrderLines data - this Call API screen containing a string fields for Status, StatusMessage, Industry, CompanyName, CompanyID and a multi-line string field for Results - this screen was created using the Multi-tile Tile with Buttons template
Tip |
---|
If you are completing this chapter as part of the Actionflow course and using a training instance, the data and screens have already been pre-loaded into the Actionflow Advanced Application. For this example, we'll be working on the Company OrdersCall API screen. |
Stop Multiple Processes Running While Performing Data ImportAdd Authentication to API Calling Actionflow
In this example, we'll create an Actionflow to import the AdditionalCompanies_Processed data and add the Status of New to each company on that table before adding it to the Companies table. We'll add this Actionflow to an Exclusion Group with other Actionflows on the same screen so that other processes cannot be triggered while the import is taking place.
Image Removed
Actionflow Setup
Open the Company Approval Review screenCreate an Actionflow on the Import button to import the AdditionalCompanies_Processed data- Name:
ImportCompanies
- If you have completed the Actionflow Intermediate Course, chapter 2.15 Analysis Action Configuration, this Actionflow setup is similar
Add a add authentication to the Actionflow that calls that API
NEED GIF ONCE NO BEAN ERROR MESSAGE FIXED
Prerequisites
For this example, we'll modify an API End Point Actionflow containing company data to only allow authenticated calls and we'll add secret key details to an Actionflow that calls the API.
The two Actionflows that will be modified were created in 3.01 Setting up an API End Point. If you have not completed this chapter, expand the section below and follow the steps to create the Actionflows.
Expand |
---|
title | Create API End Point Actionflow and Call API Actionflow |
---|
|
Insert excerpt |
---|
| 3.01 Setting up an API End Point |
---|
| 3.01 Setting up an API End Point |
---|
name | example |
---|
nopanel | true |
---|
|
|
Enable Authentication on API End Point Actionflow
- Open the API Company Data Actionflow
- On the toolbar click
Insert excerpt |
---|
| _property_settings |
---|
| _property_settings |
---|
nopanel | true |
---|
|
- In the API section, disable actioncalculateactioncalculate action to the canvas and connect Allow Anonymous Connection
- This will then only allow authenticated calls to the API
- the changes
Create Authentication User
- In the
Insert excerpt |
---|
| _repository |
---|
| _repository |
---|
name | full |
---|
nopanel | true |
---|
|
, expand the inputinput node to it - On the Calculate action, add the following Output Attribute that will be used to update the Status of all imported companies:
- Name:
Status
- Type:
String
- Expression:
"New"
- On the Calculate action, add another Output Attribute that will be used to add a 20 second delay into the Actionflow, this will simulate a large data import and allow time to trigger the Actionflow twice:
- Name:
Delay
- Type:
Integer
- Expression:
sleep(20)
- This will add a delay into the Actionflow for demonstration purposes. See sleep
- Add a
Insert excerpt |
---|
_action_analysis | _action_analysis | nopanel | true |
action to the canvasOn its Properties, in the Tables section, click the section - Click
Insert excerpt |
---|
| _add_icon |
---|
| _add_icon |
---|
nopanel | true |
---|
|
to create a new user who will be able to run the API- Login:
apiagent
- First Name:
API
- Surname:
Agent
- Password:
Phixflow123!
- Enabled:
Insert excerpt |
---|
| _toggle_on |
---|
| _toggle_on |
---|
nopanel | true |
---|
|
- the user
Create Role
We need to create a role then assign the privilege and user group(s) to it.
- In the tables
_tables | name | iconrepository | | _repository |
---|
nopanel | true |
---|
|
for the application (not the full repository), expand the application you're working in - Expand icon
- Drag across the AdditionalCompanies_Processed table from the Repository to the Analysis action properties
Connect the Calculate action to the Analysis action and map across the attribute
Expand |
---|
|
Image Removed
|
Table Attributes Setup
- On the Analysis Model, Actionflow Advanced Data, click on the table, AdditionalCompanies_Processed
- Double-click on the attribute, Status, and change the Expression to
_context.Status
- This is then referring to the attribute setup on the Calculate action
- Save the Analysis Model
Combine Data & Display
- On the Actionflow, create a and create an New Role by clicking
Insert excerpt |
---|
| _addIcon |
---|
| _addIcon |
---|
nopanel | true |
---|
|
- Pin the tab as we will need it to remain open
- Name:
GenerateAPIToken
- In the Privileges section, click
Insert excerpt |
---|
| _privilege |
---|
| _privilege |
---|
nopanel | true |
---|
|
- Search for the privilege, Use API Key and drag it into the Privileges section of the Role
Insert excerpt |
---|
| _property_settings |
---|
| _property_settings |
---|
nopanel | true |
---|
|
Image Added- the changes
- In the
Insert excerpt |
---|
| _actionuser_viewgroup |
---|
| _actionuser_viewgroup |
---|
nopanel | true |
---|
|
action with the Primary Table, AdditionalCompanies_Processed, and connect the Analysis action to the View action - In its Properties, in the Data Retrieval Options section, set the Data Range to Latest
- This will ensure that this data isn't continuously added if the Actionflow is run repeatedly
For the Output Attributes section, click the section, click Insert excerpt |
---|
| _user_group |
---|
| _user_group |
---|
nopanel | true |
---|
|
- Add a new User Group called
APIUsers
- In the Users section, click
attributes_icon_attributes_user | | _user |
---|
name | icon |
---|
nopanel | true |
---|
|
icon and drag across
all attributes
Create a - your API Agent user into the Users section
- Close the Users window
- Click
_action
_action
action to save the data to the Companies table- In its Properties, in the Basic Settings section, set the Type to Insert and
- on the User Group tab
- Click back onto the GenerateAPIToken Role tab
- Drag the APIUsers user group into the toggleontoggleon toggle on Auto Save AttributesConnect the View to the Save action and map across all attributes
Image Removed
Expand |
---|
|
Image Removed
|
Setting the Exclusion Group
- Open the Actionflow section of the GenerateAPIToken Role
- the changes
Image Added
Generate Authentication Token
- In the
Insert excerpt |
---|
| _property_settings_property_settingsrepository |
---|
| _repository |
---|
name | full |
---|
nopanel | true |
---|
|
, expand the - Under Basic Settings, populate the Exclusion Group field with any text, e.g.
Import
Image Removed
Add the same Actionflow to the Import button the Company Management screen
Expand |
---|
|
On the ImportCompanies Actionflow, open the section - Double click on the API Agent user
- Hover over the 3-dot more menu in the top right corner
- Click Generate API Key
- Copy the value displayed and store it somewhere safe
Image Added
Send Authorization
- On the screen, Company Call API, open the Actionflow on the Call API button
- Click on the HTTP Action, Call API, to open its
Insert excerpt |
---|
| _property_settings |
---|
| _property_settings |
---|
nopanel | true |
---|
|
- , hover over the In the Secret Key Details section, click
Insert excerpt |
---|
| _add_icon |
---|
| _add_icon |
---|
nopanel | true |
---|
|
- Name: APIKey
- Enabled:
more
options
more_optionsname | icon
icon and choose - the changes
- Secret: click
repository
find
repository
find
- Open the Company Management screen and drag the highlighted Actionflow from the Repository onto the Import button
- This will create another instance of the same Actionflow
Testing
- Open the Company Approval Review and Company Management screens
- Ensure both screens are
- In the Secret field, paste the API Key you copied above
- the changes
Image Added
- In the Headers section, click
Insert excerpt |
---|
| _add_icon |
---|
| _add_icon |
---|
nopanel | true |
---|
|
- Name:
Authorization
- Expression:
_datasource.APIKey
Insert excerpt |
---|
| _locksave |
---|
| _locksave |
---|
nopanel | true |
---|
|
the changes
Image Added
edClick Import on one screen then press Import on the other screenA warning message should appear
Image RemovedTesting
- Open the screen, Company Call API
- Attempt to run the Actionflow on the Call API button - you should see an error message
- Log out and login as the user API Agent
- Attempt to run the same Actionflow and it should run
- Remember to log out and back in with your normal login credentials before continuing to the next chapter
