reddit-mastodon-crossposter/reddit.py

26 lines
626 B
Python
Raw Normal View History

2022-12-09 00:04:01 +01:00
"""Initialize PRAW"""
2024-01-04 19:39:41 +01:00
from os import getenv
2022-12-09 00:04:01 +01:00
import praw
from dotenv import load_dotenv
2023-08-01 18:59:46 +02:00
# ----- load .env ----- #
2022-12-09 00:04:01 +01:00
load_dotenv()
2023-08-01 18:59:46 +02:00
# ----- initialize reddit ----- #
2022-12-09 00:04:01 +01:00
reddit = praw.Reddit(
client_id = getenv("REDDIT_CLIENT_ID"),
client_secret = getenv("REDDIT_CLIENT_SECRET"),
redirect_uri = "http://localhost:8080", # does not matter what is here
user_agent = getenv("REDDIT_USER_AGENT")
)
# get auth URL
# print(reddit.auth.url(scopes=["identity", "read"], state="...", duration="permanent"))
# get refresh token
# print(reddit.auth.authorize(getenv("REDDIT_AUTH_TOKEN")))
# print(reddit.user.me())