Retrieving an Access Token Through OAuth on Alteryx

by Erlina Cahyadi

My last blog post covered how to access an API through the basic authentication process. This blog will cover how to access an API using the OAuth process. This process requires users to complete one more extra step before retrieving all the data needed from a specific site. Unlike basic authentication, where the API directly provides an authentication key to access the data, the OAuth-based APIs will provide a client key and a client secret to retrieve an access token, which will be used as the authentication key.  Please note that this blog is tailored toward the Petfinder API. Other APIs may have additional requirements.

Typically in the API documentation, a request URL, a client ID, a secret key, and some variation of “grant type client credentials” will be provided. The Petfinder API documentation provides the below cURL command, which is a command tool that allows data to be exchanged to and from a server. The ‘&’ signs are used as delimiters to indicate how to structure the required fields. Please note that fields and keys may be case-sensitive and should reflect what is provided in the documentation.  

Based on the above documentation and my Petfinder API account, the required fields are:

   URL: https://api.petfinder.com/v2/oauth2/token

   client_id: {a1bcD2EfG3H4i567Jkl9MNoPQrSTu0VwXyZ-ID}

   client_secret: {A1bCDe2fGHiJ34kLM5n6O7PqR8sTu9Vwx0yZ}

   grant_type: client_credentials

These are the fields that will be inputted into a text input tool to retrieve the access token, as shown below. Please not that the curly brackets for the client_id and client_secret are excluded.

Afterward, connect the text input tool to a download tool to put this request into action.

Once connected, the download tool should automatically assign the URL field to the Field section under the Basic tab. Otherwise, select the desired URL field that requests the access token.

With the basic authentication process, the authentication key is typically used in the Headers tab.  However in this case, the Headers section is not necessary.


Moving onto the Payload tab, select the required fields under the “And values from these fields” section and choose POST as the HTTP action.

Alternatively, a formula tool could be used to form a string/body field to match what was given in the documentation using the necessary fields.

So instead of selecting the required fields, use the newly created Post field under the “Take Query String/Body from Field” section.

Now run the workflow. A DownloadData and DownloadHeaders column will be generated to indicate if the user successfully received authorization. For the Petfinder API, under the DownloadData column, it will output a token type, expiration time, and access token. From here, the data can be formatted to show only the access token. This can be used to access the data, as one would with the basic authentication process.

Now you know how to retrieve an access token on Alteryx using OAuth and can have fun with the data!