prawcore.exceptions.OAuthException error even though I checked credentials

Viewed 339

I am getting a credential error but I am not understanding why. I feel as though I've triple checked that they are correct and also manually logged in. My code is shown below

import os
from dotenv import load_dotenv
import praw
load_dotenv()

reddit = praw.Reddit(client_id=os.getenv('reddit_personal_use'),
                     client_secret=os.getenv('reddit_api_key'),
                     user_agent=os.getenv('reddit_app_name'),
                     username=os.getenv('reddit_username'),
                     password=os.getenv('reddit_pw'))

print(reddit.user.me())

I saved my .env file in the root of the project directory and have it listed as

reddit_api_key=####
reddit_username=####
reddit_pw=####
reddit_app_name=some words here that explain my code, author /u/username
reddit_personal_use=###

Should I maybe be adding quotes to all the values for the key value pairs? When I run the print statement to check that the credentials went through OK I get:

response, payload["error"], payload.get("error_description") prawcore.exceptions.OAuthException: invalid_grant error processing request

Should I be making any other changes that I may not be making? Also in the Reddit API request there is a section for name. Should the name on the API request match the user_agent name? In examples I've seen online they never fully say if they should match, they just write that it should be unique and include your username. But I am confused what the name part in the request is then:

enter image description here

1 Answers

There are a series of unwritten/undocumented reddit api rules that you can only find on /r/redditdev. Per the link

If your credentials are right, consider trying the following

  1. Change your user agent to omit the word bot...
  2. Add the bot name as a developer onto the application
Related