Files
earthporn_analyzer/earthporn_analyzer.py
Nico Melone 9ba9eebaf2 prototyping
2022-03-09 15:34:26 -06:00

27 lines
1.0 KiB
Python

import requests
import requests.auth
import json
CLIENT_ID = "wRuNZ_TWBQhcN-uQxfajPA"
CLIENT_SECRET = "ue20Q8ev6Z6Fa9r-PN_TETf-YItXoA"
CODE = "code"
URI = "uri"
GRANT_TYPE = "password"
USERNAME = "ExplodingLlama"
PASSWORD = "p9nyHFftTPDN0XkzoPYN"
VERSION = "0.0.1"
AGENT = f"python:com.llamallama.earthporn_analyzer:v{VERSION} (by /u/ExplodingLlama)"
client_auth = requests.auth.HTTPBasicAuth(CLIENT_ID, CLIENT_SECRET)
#post_data = {"grant_type": GRANT_TYPE, "code": {CODE}, "redirect_uri": {URI}}
post_data = {"grant_type": GRANT_TYPE, "username": USERNAME, "password": PASSWORD}
headers = {"User-Agent": AGENT}
response = requests.post("https://www.reddit.com/api/v1/access_token", auth=client_auth, data=post_data, headers=headers )
print(response.json())
response_json = response.json()
"""
token = response_json['access_token']
headers = {"Authorization": f"bearer {token}", "User-Agent": "python:com.llamallama.earthporn_analyzer:v0.0.1 (by /u/explodingllama)"}
response = requests.get("https://oauth.reddit.com/api/v1/me", headers=headers)
response.json()
"""