Hello!
I am not having much luck translating the following Python API request into the Download tool to perform the same function. I am trying to receive an access token to use the Reddit API. I'm also having trouble inside of Python converting the json response to a dataframe to export and thought I'd use the download tool instead. Can anyone advise how to set this up in the download tool? I think the beginning with BasicAuth is giving me trouble.
from ayx import Alteryx
import requests
import requests.auth
import pandas as pd
client_auth = requests.auth.HTTPBasicAuth('client_id', 'client_secret')
post_data = {"grant_type": "password", "username": "myusername", "password": "mypassword"}
headers = {"User-Agent": "ChangeMeClient/0.1 by myusername"}
response = requests.post("https://www.reddit.com/api/v1/access_token", auth=client_auth, data=post_data, headers=headers)
response.json()
In the download tool:
Solved! Go to Solution.
@Anthony_A2 I think you're pretty close. Hopefully the attached gets you there. I got it working on my side with a dummy account I setup.
As you figured out, the issue is the client id/secret. You need to combine them with a : and Base64 encode them. The Base64 encoder tool with alteryx sometimes has problems with more than 1 record, so I use the Blob Convert tools. In the header, you call it Authorization and then add "Basic " (with a space!) before your encoded client id/secret. The authorization is always the hardest part of setting up an api call.
User | Count |
---|---|
19 | |
15 | |
13 | |
9 | |
8 |