Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import json
- # config
- client_id=''
- client_secret=''
- username = ''
- password = ''
- subreddit_name = '' # replace with your subreddit name
- domains = [] # comma separated domains go here
- user_agent = 'reddit alpha whitelist uploader v1.0 by u/Jakeable running as u/' + username
- # request bearer token
- client_auth = requests.auth.HTTPBasicAuth(client_id, client_secret)
- post_data = {"grant_type": "password", "username": username, "password": password}
- headers = {"User-Agent": user_agent}
- response = requests.post("https://www.reddit.com/api/v1/access_token", auth=client_auth, data=post_data, headers=headers)
- bot_auth = response.json()['access_token']
- # update whitelist data
- bearer = "bearer " + bot_auth
- headers = {"Authorization": bearer, "User-Agent": user_agent, "Content-Type": 'application/json'}
- url = "https://oauth.reddit.com/api/v1/" + subreddit_name + "/submit_validations"
- data = {"ruleLinkListPermission":"whitelist","ruleLinkWhitelist":domains}
- resp = requests.patch(url, headers=headers, data=json.dumps(data))
- print(resp.text)
Add Comment
Please, Sign In to add comment