Search code examples
pythonredditpraw

Raise ClientException(required_message.format(attribute)) praw.exceptions.ClientException: Required configuration setting 'client_id' missing


I am not sure how to make this work. I also can't find client_id in my app. I just see the app secret there:

>>> import praw
>>> r = praw.Reddit(user_agent='custom data mining framework',
... site_name='lamiastella')
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/usr/local/lib/python2.7/dist-packages/praw/reddit.py", line 101, in __init__
    raise ClientException(required_message.format(attribute))
praw.exceptions.ClientException: Required configuration setting 'client_id' missing. 
This setting can be provided in a praw.ini file, as a keyword argument to the `Reddit` class constructor, or as an environment variable.

here is my praw.ini file which I am not sure if it's correct or has all the necessary fields:

[lamiastella]
domain: www.monajalal.com
user: lamiastella
pswd: mypassword

any help is really appreciated.

**Can I retrieve images using praw as well from reddit or what do you suggest?


Solution

  • The error is caused from a missing client_id (which is your unique API key and secret for the Reddit API) in your praw.ini file or in your Python script.

    In your script you could have something like:

    r.set_oauth_app_info(client_id='stJlUSUbPQe5lQ',
    ...                      client_secret='DoNotSHAREWithANYBODY',
    ...                      redirect_uri='http://127.0.0.1:65010/'
    ...                                   'authorize_callback')
    

    https://praw.readthedocs.io/en/stable/pages/oauth.html?highlight=client_id#step-2-setting-up-praw

    Or set up in the praw.ini file as described in the link below:

    https://praw.readthedocs.io/en/stable/pages/configuration_files.html#configuration-variables

    If you have already signed up for access to the reddit API, it says:

    https://www.reddit.com/wiki/api

    OAUTH Client ID(s) *

    • if you don't have yet, please email [email protected] when received or when you add additional

    You can get your client_id from your app in: https://www.reddit.com/prefs/apps

    enter image description here

    In this example from their documentation (under the API app title): the client_id=p-jcoLKBynTLew