For all that love I have for twitch streams, I decided to connect to twitch API. After failing to connect for 30 minutes. Boom! Here’s the news, Twitch API uses OAuth 2.0! So, quick change of plans, I switched to another simple API for the preso.
However, failure to connect to twitch kept haunting over the weekend and made me realise that I need to understand the concepts behind connecting to API using OAuth2.0 Authentication. Hence, this blog to unravel and simplify the concepts and connect using Alteryx.
Choosing the Auth flow:
After creating a developer account in twitch, created an application in the developer console which then provided a Client-Id and Client secret. (just a two-step process)
Understanding Access Tokens:

Download Tool Setup – Receiving Token :
Text Input Tool:
Drag text inpput tool and create four columns as below.

Formula Tool:
In the formula tool create a new column concatenating as below.

Download Tool: Basic Tab
Select the URL column (Contains URL to receive token) in the URL field.

Download Tool : Payload Tab
In the Payload tab, select “Take Query String/Body from field” and in the drop down choose the column “post” which was created in the formula tool .

Below is the initial flow to receive access token.

Output received with access token, will be used in flow along with API endpoint.

Download Tool Setup – Passing API :
I’m interested only in twitch Live streams data, so, my API request is as follows. By default, the following request will provide top 20 most active streams. The results can be increased by adding optional query parameters to the API request
curl
-XGET
'https://api.twitch.tv/helix/streams'\
-H'Authorization: Bearer <Received from Oauth server>'
\
-H
'Client-Id: CLIENTID'
Using the Formula tool, concatenate the work “Bearer” to the received token and name the new column as “Authorization”

Download Tool: Basic Tab
In the Basic Tab, Select the column “Endpoint” (Which was created using Text Input Tool) in the URL field.

Download Tool: Header Tab
In the Header Tab, Select the Column “Authorization” (Which contain the word ‘Bearer’ and the Token received from the initial flow) and “Cliend-Id”.

Download Tool: Payload Tab
Since twitch requires API request in the “Get” action, select “Get (or FTP)” from the HTTP action’s drop-down options.

Output :
Here’s the link to download Alteryx Macro flow and Tableau Dashboard.
Alteryx: Twitch Macro
Tableau: Twitch Top20 Live Stream


Feel free to drop me some comments if you find any easy or alternate methods.