Download Training Materials
Overview:
This exercise sets up an API Integration session using Automate's API Integration framework. While Automate supports multiple authorization protocols, in this example we will be using OAuth.
Before you can access APIs using OAuth, you will need to register the application with the Provider, in this case Google. The process for registering an application is somewhat different from provider to provider, and as such, is not covered in this document. However, here are some helpful links to Google documentation describing the process.
Register app at: https://console.developers.google.com/
Recommended reading: Using OAuth 2.0 to Access Google APIs | Google Identity | Google Developers
Note: you will need to have a Google account to create an app.
As part of the registration process, you will need to provide "Authorized redirect URIs" for Google to communicate with Automate. For Automate OAuth, use http://localhost:8080
Note: The port (i.e., 8080) must be open to receive http messages from Google. 8080 is the default port chosen by Automate. You can choose to change this port.
When registration is complete, copy the Client ID and Client Secret as you will need these to setup the OAuth connection. Note that the Client ID and Secret are your application’s unique username and password used to communicate with Google.
Create the HTTP Session:
To create the session, you will need to provide the Authorization URL, the Access Token URL, the Client ID, the Client Secret, and the Authorization Scope. These Authorization and Token URLs are provided by the provider, in this case Google. For Client ID and Secret, use the unique values created for your app.
Make sure the callback port number matches the port number used when creating the app (e.g., 8080).
The Scope represents the information the app is requesting permissions to access. These values are specified by the provider as well.
Next, let's setup the HTTP Session:
- Create a new Task and give it a name (e.g., HTTP OAuth2)
- Add an HTTP Define Activity to create an HTTP Session.
- For the Authentication type, choose OAuth2.0
- You will need to enter the Authorization URL and Access Token URL specified by Google.
- You will need to enter the Client ID and the Client Secret for the App that you registered with Google.
- For the Authorization Scope, provide the scope of this App, that is, what APIs this application intends to access. (For example, “https://www.googleapis.com/auth/userinfo.profile” to access the user’s profile.)
- If you are not using the default Port for the callback Port (i.e., 8080), make sure to update the port.
- Save the Task.
Now you are ready to run the Task. When you first run the Task you will be prompted to log into your Google account and grant permissions to the App. Once you have granted access to the App, you will not be asked to grant access to the App in subsequent invocations of the Task, unless Google has expired your access. This may happen from time to time as a security measure.
Now you can access the Google APIs. Note: Based on the permissions requested for the App, the App will only be allowed to access those APIs. In this case however, the App will be limited in the APIs you can access. In order to access the full list of APIs, you will need to validate the App with Google.