Im trying to learn PRAW
. Doing everything according to official documentations but start getting login error (output below)
What do I wrong? How can I fix that?
All creds
are correct.
import json
import praw
import requests
subr = 'test'
credentials = 'client_secrets.json'
with open(credentials) as f:
creds = json.load(f)
reddit = praw.Reddit(client_id=creds['client_id'],
client_secret=creds['client_secret'],
user_agent=creds['user_agent'],
redirect_uri=creds['redirect_uri'],
pasword=creds['password'],
username=creds['username'])
title = "PRAW documentation"
url = "https://praw.readthedocs.io"
reddit.subreddit("test").submit(title, url=url)
Output:
RedditAPIException: USER_REQUIRED: 'Please log in to do that.'
the easiest way to login to reddit using PRAW is by using this code from the docs
- client_id is the "script" you are given by reddit when you create your app
- client_secret is the API key that you are given by reddit from when you create the app
- password is your reddit accounts password
- user_agent is the description of your app
- and username is your username of your reddit account
reddit = praw.Reddit(
client_id="client_id",
client_secret="client_secret",
password="password",
user_agent="user_agent",
username="username",
)