-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.py
32 lines (26 loc) · 852 Bytes
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File loading reddit client
import sys
import praw
import os
from dotenv import load_dotenv
load_dotenv()
def client():
"""
Setup Reedit API authentication.
@returns: praw Reddit object
"""
try:
clientId = os.environ["CLIENT-ID"]
clientSecret = os.environ["CLIENT-SECRET"]
password = os.environ["PASSWORD"]
userName = os.environ["REDDIT-USERNAME"]
userAgents = os.environ["USER-AGENTS"]
reddit_client = praw.Reddit(client_id=clientId,
client_secret=clientSecret,
password=password,
username=userName,
user_agent=userAgents)
except KeyError:
sys.stderr.write("Key or secret token are invalid.\n")
sys.exit(1)
return reddit_client