提升ClientException(required_message.format(attribute))praw.exceptions.ClientException:必需的配置设置' client_id'失踪

时间:2016-09-15 23:07:18

标签: python reddit praw

我不确定如何使这项工作。我也无法在我的应用中找到client_id。我只是在那里看到app秘密:

>>> 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.

这是我的praw.ini文件,我不确定它是否正确或包含所有必填字段:

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

任何帮助都非常感谢。

**我可以使用reddit中的praw来检索图像,或者你的建议是什么?

1 个答案:

答案 0 :(得分:2)

错误是由case ComebackLater => log.info("grumble, grumble") context.system.scheduler.scheduleOnce(300.millis) { coffeeSource ! EspressoRequest } 文件或Python脚本中缺少的client_id(这是您唯一的API密钥和Reddit API的秘密)引起的。

在您的脚本中,您可以使用以下内容:

praw.ini

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

或者按照以下链接中的说明在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/configuration_files.html#configuration-variables

如果您已注册访问reddit API,则会说:

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

  

OAUTH客户端ID *

     
      
  • 如果您还没有,请在收到时或在您添加其他内容时发送电子邮件至api@reddit.com
  •   

您可以从您的应用中获取praw.inihttps://www.reddit.com/prefs/apps

enter image description here

在此示例中,来自他们的文档(在API应用程序标题下):client_id