Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

praw.Reddit instance does not use a unique user-agent #63

Closed
pricebenjamin opened this issue Sep 17, 2019 · 1 comment
Closed

praw.Reddit instance does not use a unique user-agent #63

pricebenjamin opened this issue Sep 17, 2019 · 1 comment

Comments

@pricebenjamin
Copy link
Contributor

The reddit API rules ask that the supplied user-agent string be

unique and descriptive, including the target platform, a unique application identifier, a version string, and your username as contact information, in the following format:
<platform>:<app ID>:<version string> (by /u/<reddit username>)

Currently, all fresh_script users have the same user-agent, defined by the createPrawConfig function:

fresh_script/fresh.py

Lines 56 to 60 in 29a482a

r_config['bot1'] = {
'client_id': client_id,
'client_secret': client_secret,
'user_agent': 'FreshScript'
}

The createPrawConfig function creates a site_name called 'bot1' in a local praw.ini file. This site_name is then used to create a praw.Reddit instance within main:

reddit = praw.Reddit('bot1')

One solution would be to override the user_agent string when creating the praw.Reddit instance:

user_agent = ' '.join([
    "Python3:FreshScript:(commit 29a482a)",
    "(by /u/<reddit_user>)",
    "(https://github.com/amcquade/fresh_script)"
])
reddit = praw.Reddit('bot1', user_agent=user_agent)

A helper function to generate the user string would be useful. We would also need to store the user's reddit username in one of the configuration files (see #62).

@masihtamsoy
Copy link

Hi, want to look into this issue. Please provide me initials to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants