- Purpose of the Article: This blog explains about how to apply Oauth Policy for a recipe in Workato.
- Intended Audience: Workato Developers
- Tools and Technology: Workato
- Keywords: Recipe, API Client, API Collection
Recipe: Recipe is an automated workflow that connects your applications. Recipes consist of triggers and one or more actions. When the recipe starts, it waits for a triggering event to run the actions.
API Collection: API Collection consists of endpoints with a shared access model so that they can be managed together.
API Client: It enables you to apply the best security policies by creating several clients with configurable access to each endpoint. Only a single header is required for API client Requests authentication.
Create a recipe by selecting the BUILD AN API ENDPOINT trigger for getting the URL.
Enter the recipe name and select the location where the recipe needs to be stored. Users can choose the earlier created projects or can create a new project.
Select the new project and enter the project name and description.
Add the response for the trigger as shown in the below image.
Take a sample logger by selecting “Logger by Workato”, place the message as ‘Authentication successful’ and save the recipe and click on exit.
Click on ‘start recipe’ it will wait for the request as shown in the below image.
Navigate to the API platform to apply the Policy for the recipe. In the left side menu, click on API Platform, as shown in the below image.
After selecting the API Platform, the user can see multiple options like Dashboard, API collections, etc.,
Now select the API collection. Click on create new API Collection. It will pop up a new window, and then select the option USE EXISTING RECIPE and select the folder where the recipe had been stored.
Click on next, it will show the recipes which are available in the project. Users can select a single or multiple recipes to create a collection.
Select the recipe which has been created earlier and then select the request method (GET, POST, etc.,) and request path.
Click on Next and enter the Collection Name and the version of the collection.
Click on ‘create the collection’.
Click on View API collection. In this, recipes and their state (Active or Inactive) are shown. By default, it will be in the Inactive state. Enable the recipe by clicking on the inactive state to the active state.
Navigate to API Platform and select the Clients option and create a new client for the collection which has been made earlier.
Click on New Client., A new pop up that consists of Name, description, and client logo will appear.
Create an access profile for the collection, Click on New access profile. It will ask for the profile name and API Collection that needs access from this profile. Select the Authentication method as OAuth 2.0 Policy, as shown in the below image.
Click on the following and create access profile, client ID and client secret will be generated for the profile. The generated id and Secret need to be used for requesting URLs. Copy the generated ID and Secret.
Select the recipe name which is shown below, after creating the access profile. Copy the URL by clicking on the recipe name (E.g., test). Now the recipe has been secured by OAuth 2.0 Policy, and it is available for testing.
No Authorization has been selected.Test the URL. As shown in the above image, it will throw an error.
Select the Authorization as OAuth 2.0 and place the client id and client secret as shown in the below image.
Use the following URL for Access Token URL à https://apim.workato.com/oauth2/token
Select the Add authorization data to Request Headers.
Generate the new access token and click on the user token.
The generated token will be used in the request. It will provide a successful response as shown in the below image.
Observe the successful jobs in the jobs section of that recipe.
Author Bio:
Sivaprasad Reddy BUNGA
Technical Consultant - Enterprise Integration
I have 2 years of experience in Integration and as a part of it, I have worked on Workato, in which I have been involved in multiple projects where I have used lookup tables, Environment Properties, applied policies for a recipe, and used Programming Languages like Python.