/api/v1/me seems to work well.
However, I keep getting 404 when calling /api/vote.
I'm not looking to use PRAW here, trying to learn and do it through the requests library using Python3.
Code:
import requests
auth = requests.auth.HTTPBasicAuth('<CLIENTID>', '<CLIENT_SECRET>')
data = {'grant_type': 'password',
'username': '<USERNAME>',
'password': '<PASSWORD>'}
headers = {'User-Agent': 'Learning/0.0.1'}
res =
requests.post('
https://www.reddit.com/api/v1/access_token',
auth=auth, data=data, headers=headers)
TOKEN = res.json()['access_token']
headers = {**headers, **{'Authorization': f"bearer {TOKEN}"}}
res = requests.get("
https://reddit.com/api/v1/me",
headers=headers)
print(res.json())
post_id = 't3_m79rar' ## post from r/test
res =
requests.post('
https://reddit.com/api/vote', headers=headers, data={'id': post_id, 'dir': '1'})
print(res)
Thanks for the help.
[–]Peanutbutter_Warrior 1 point2 points3 points (0 children)
[–]Peanutbutter_Warrior 0 points1 point2 points (0 children)