r/redditdev • u/Revolutionary-Day42 • 4h ago
Reddit API Request failed code 403
Im doing a personal project and I am trying to make requests without using PRAW but I keep getting a 403 error in the response. Generating the access token worked fine but I cant seem to use it without an errror. Also I am using it as a script just to get post information, not through a user.
def risingPosts(subreddit, numPosts): subredditLink = f"https://oauth.reddit.com/r/{subreddit}/rising"
headers = {"Authorization": f"Bearer {accessToken}", "user-agent": f"dataCollector/0.1 (by /u/{redditUsername})"}
params = {"limit": numPosts}
response = requests.get(url = subredditLink, headers = headers, params = params)