Write REST API robots with OAuth
For Basic Engine Robots, this topic shows how to write a robot that accesses a REST API that authenticates with OAuth credentials.
As an example, we use the REST API to obtain the most recent statuses by the authenticating user and the followed users.
-
Start
Design Studio
and create a new Basic Engine Robot.
Do not enter a URL in the wizard. You will not be able to access the REST API before authentication.
- To the robot, add a new variable of complex type OAuthCredentials and select Use as Input.
- In the serviceProvider field, type then name of the service provider.
- Enter the access token and access token secret that were obtained when you went through the user authorization process in the Management Console.
- Enter the consumer key and consumer secret for the service provider's application.
- Click OK.
-
Click
Configure Robot
.
The robot configuration window appears.
- On the Basic tab, click Configure.
- On the All Loading tab, locate Credentials and switch it from Standard user name/password authentication to OAuth.
-
Select the input variable you just added.
You should now see the XML that has been returned, containing the most recent statuses in the user time line.
-
Click
OK in both dialogs.
The robot is now configured to use OAuth and use the specified credentials when running in Design Studio. You can now start accessing the API. For example, to see a collection of the most recent posts by the user, access the URL https://api.serviceprovider.com/1.1/statuses/user_timeline.json.