This commit is contained in:
Nico Melone
2022-02-24 17:25:41 -06:00
parent e53c508537
commit af5a5e2ed6

21
earthporn_analyzer.py Normal file
View File

@@ -0,0 +1,21 @@
import requests
import requests.auth
import json
CLIENT_ID = "0U8ldg0566wsdjrf7lUDlQ"
CLIENT_SECRET = "xq7JLuAlVAWun0p_LqOfS3gyCjgN8A"
CODE = "code"
URI = "uri"
client_auth = requests.auth.HTTPBasicAuth(CLIENT_ID, CLIENT_SECRET)
post_data = {"grant_type": "authorization_code", "code": {CODE}, "redirect_uri": {URI}}
headers = {"User-Agent": "python:com.llamallama.earthporn_analyzer:v0.0.1 (by /u/explodingllama)"}
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()
"""