Engine Works

Under the hood of Alteryx: tips, tricks and how-tos.
StephenW
Alteryx Alumni (Retired)

Have you ever wanted to bring data from a Google service into an Alteryx workflow?  You're in luck!  Use the Google API: Retrieve Access Token macro to generate the Authentication token needed to make calls against Google APIs.  Not familiar with Authentication tokens?  Read the recent blog post, REST APIs Part 2 - Authentication, for a great overview.  Don't have a specific Google API in mind?  Use the Google APIs Explorer to see what's available.

 

 

What's Needed

The Google API: Retrieve Access Token macro is configured to use a Client ID, Client Secret, and Refresh Token associated with a specific Google API and account.  The Alteryx Knowledge Base article, How to Create Google API Credentials, walks you through how to obtain these.

 

 

What Happens

The Google API: Retrieve Access Token macro takes Client ID, Client Secret, and Refresh Token fields from the macro input and POSTs them as a Payload to https://accounts.google.com/o/oauth2/token. A JSON response is received that contains access_token, token_type, and expires_in.  This response is parsed and output as an Authorization token.

 

JSON Response from API:

JSON Response from APIJSON Response from API

 

Screenshot of the Google API: Retrieve Access Token macroScreenshot of the Google API: Retrieve Access Token macro

 

 

How to Use It

The Google API: Retrieve Access Token macro is used in conjunction with an Append Field tool to add the newly acquired Authorization token to your data stream.  The Authorization token can then be used as a Header parameter within the Download tool you're using to make your API call.

 

A screenshot from a workflow containing the Google API: Retrieve Access Token macroA screenshot from a workflow containing the Google API: Retrieve Access Token macro

 

 

Google API Ideas

In addition to the Google APIs Explorer, another great resource, for exploring available API methods, is the Google OAuth 2.0 Playground.  After authorizing an API, you can list it's possible operations.  This can be helpful in understanding how to configure the Download tool.

 

Google OAuth 2.0 Playground:

Screenshot of the Google OAuth 2.0 PlaygroundScreenshot of the Google OAuth 2.0 Playground

 

 

Create Your Own

Download the attached Google API: Retrieve Access Token macro to begin accessing Google APIs.  Never installed a macro?  Reference How to Install a Macro.  Post interesting use cases you've used this macro and the Download tool for in the comments.

Stephen Wagner
Product Manager, Technology Alliances

Stephen Wagner is a Product Manager, Technology Alliances with a passion for enabling users to take full advantage of the Alteryx platform. Stephen’s background includes analyzing sales, marketing, and operational data for a Fortune 50 retailer, as well as data visualization development as an Analytics Consultant.

Stephen Wagner is a Product Manager, Technology Alliances with a passion for enabling users to take full advantage of the Alteryx platform. Stephen’s background includes analyzing sales, marketing, and operational data for a Fortune 50 retailer, as well as data visualization development as an Analytics Consultant.

Comments