Action Use Case
  • 5 Minutes to read
  • Dark
    Light
  • PDF

Action Use Case

  • Dark
    Light
  • PDF

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:
  1. Send a request to generate a token (that request requires a preliminary step- creating a connection using oauth2 authentication method)
  2. Post a request to create a job to generate a report according to a given meta-data of the report.
  3. Wait until the job is completed
  4. 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:

https://developer.yahoo.com/oauth2/guide/flows_authcode/#step-5-exchange-refresh-token-for-new-access-token=

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:

    https://developer.yahoo.com/apps/

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.

  1. 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.
  2. Enter the OAuth2 Authentication details, such as client_id, client_secret, scope etc.
  3. Click on Submit OAuth2 . A pop up should appear.
  4. If nothing happens, check if browser blocked the popup in the right side of the URL in your browser.
  5. 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.
  6. After logging to Yahoo the application will ask for permission. Accept it in order to complete the authentication process.
  7. After completing the log-in process, all the authentication details will be automatically added to the connection:
  8. Those details can be used as variables, exactly like any other connection detail we would create not using the OAuth2 process.
  9. Click on Is Password in order to store any detail as password (will be stored encrypted).
  10. The only detail which is required in order to connect to Yahoo is the refresh_token . The other details can be deleted.
  11. 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.
  12. 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:

    Action Use Case-image-3

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.

  1. Select the connection we created in step 0. We’ll use the connection variables in this action.
  2. Insert the URL of the request: https://api.login.yahoo.com/oauth2/get_token
  3. According to the documentation, the request is a POST request. Change the method to POST.
  4. Action Use Case-image-4

  5. 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.
  6. Rivery supports in Basic authorization - Just select the basic authorization in the input of the Authentication type.
  7. 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.
  8. Those two details are located in the connection we’ve created before, so we can simply use those variables:
  9. Action Use Case-image-5

Configure the headers

  1. According to the documentation, we learn that the request needs to include a header of Content-type with the following value
  2. Action Use Case-image-6

Add a body to the request

  1. Body is available to input only for POST requests.
  2. According to Yahoo's documentation, the body of the request should be like that:
  3. grant_type=refresh_token&redirect_uri=https%3A%2F%2Fwww.example.com&refresh_token=a_qOmByVGTm
    

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>
    
  • [Multi-Action in Rivery](https://rivery-io.document360.io/docs/multi-actions)
Configure each of the inputs in the Actions according to the following instructions.

Was this article helpful?

What's Next