- 5 Minutes to read
Action Use Case
- 5 Minutes to read
In this step-by-step example, we’ll create a multi-action in Rivery to pull a report from Yahoo Gemini reporting API.
This example will illustrate all the different options we have in Rivery to connect to many kinds of APIs, using different kinds of HTTP requests options.
Then we’ll use this Multi-Action in a REST River in order to load the data to a target table in our cloud database.
The Yahoo Gemini process at High level
In our Yahoo example, the first step will be connecting using an Oauth2 authentication method and get a refresh token which will be used in the first action in our multi-action.
The Yahoo example process at High level:
- Send a request to generate a token (that request requires a preliminary step- creating a connection using oauth2 authentication method)
- Post a request to create a job to generate a report according to a given meta-data of the report.
- Wait until the job is completed
- Once the job is completed and the report is ready, download the report.
All of those steps can be created as Actions in Rivery and can be called inside a multi-action.
Once the multi-action is ready, we’ll execute it from a Rest river in order to load the data to our target table.
Prerequisites - Create a connection in Rivery to Yahoo
The Yahoo API requires an oauth2 authentication.
That kind of authentication requires an operating Yahoo application, and a user credentials (user email & password)
The documentation we’ll follow to create that connection is available in that Yahoo page:
Creating a new connection in Rivery can be in one of two options: When creating a new river and click on the button of “create a new connection” of in the connections screen and click on the button of new connection (in that option, you’ll have to select the data source of the connection to create- select the REST data source in the toolkits section).
If you don’t have an application, create one in that link:
The most important configuration in the application is the callback domain. The callback domain should be the domain of the callback URL mentioned in the oauth2 connection in Rivery.
Once the application is ready, copy the client id and client secret in order to use it when creating the connection in Rivery.
- In the new connection screen, insert a name to that new connection and then click on Open Oauth2 Authentication in order to open the form of the Oauth2 details.
- Enter the OAuth2 Authentication details, such as client_id, client_secret, scope etc.
- Click on Submit OAuth2 . A pop up should appear.
- If nothing happens, check if browser blocked the popup in the right side of the URL in your browser.
- If the details were accurate, a pop up with a login form to Yahoo should be opened.
Login to Yahoo with valid user name details.
- After logging to Yahoo the application will ask for permission. Accept it in order to complete the authentication process.
- After completing the log-in process, all the authentication details will be automatically added to the connection:
- Those details can be used as variables, exactly like any other connection detail we would create not using the OAuth2 process.
- Click on Is Password in order to store any detail as password (will be stored encrypted).
- The only detail which is required in order to connect to Yahoo is the refresh_token . The other details can be deleted.
- Add to the connection details also the client id and client secret of your Yahoo application. Those two details will be used later in the process.
- Save the connection and make sure to select it in the relevant action later in the process.
The complete custom connection should be looked like the following:
Those details will be used later in the process as variables that will be sent as parameters in the Actions that we’ll create.
The following steps are actions in the process that will be executed in a single Multi-Action. Each Action can be created inside the Multi-Action or as a REST Action.
Configure each of the inputs in the Actions according to the following instructions.
Step 1 - Create an Action to get a token
The details for this action are available in the last step of the Yahoo official authentication documentation .
The goal of the action is to generate an access token for a given refresh token we have configured in the connection.
- Select the connection we created in step 0. We’ll use the connection variables in this action.
- Insert the URL of the request: https://api.login.yahoo.com/oauth2/get_token
- According to the documentation, the request is a POST request. Change the method to POST.
- This request requires basic authentication. We can understand it according to the headers of the request in the documentation: Authorization Bearer dsdasd….
The authorization bearer is actually an encrypted string of the combination of a user name and password.
- Rivery supports in Basic authorization - Just select the basic authorization in the input of the Authentication type.
- Insert the username and the password . In that case, the user name is the client id of your Yahoo application, and the client secret is the client secret.
- Those two details are located in the connection we’ve created before, so we can simply use those variables:
Configure the headers
- According to the documentation, we learn that the request needs to include a header of Content-type with the following value
Add a body to the request
- Body is available to input only for POST requests.
- According to Yahoo's documentation, the body of the request should be like that:
Step 2 - Create an Action or Multi-Action Based On Yahoo's Token
The following steps are actions in the process that will be executed in a single Multi-Action.
Each Action can be created inside the Multi-Action or as a REST Action.
Follow the next docs in order to create Multi-Action and Rest Action:
<li>[REST Action ](https://rivery-io.document360.io/docs/rest-action) </li>