2016-09-15 41 views
1

我不知道如何使这项工作。我也无法在我的应用程序中找到client_id。我只看到应用程序的秘密有:Raise ClientException(required_message.format(attribute))praw.exceptions.ClientException:缺少必需的配置设置'client_id'

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

任何帮助非常感谢。

**我可以使用praw来检索图像以及来自reddit或你有什么建议?

回答

2

该错误是由您的praw.ini文件或您的Python脚本中缺少client_id(这是您唯一的API密钥和Reddit API的秘密)导致的。

在你的脚本,你可能会碰到这样的:

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

地或在下面的链接中描述的praw.ini文件设置:

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

如果您已经注册访问reddit API,它说:

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

OAuth用户端ID(S)*

  • 如果你没有还,请在收到的电子邮件时或[email protected]当您添加其他

您可以从您的应用中获得您的client_idhttps://www.reddit.com/prefs/apps

enter image description here

在这个例子中,从他们的文档(在API应用标题):所述client_id=p-jcoLKBynTLew

+0

我的r被未设置,因此我不能使用它。我在'r = praw.Reddit(user_agent ='自定义数据挖掘框架', ... site_name ='lamiastella')''中有错误,其中r已分配!我在问这个问题,看看我能在哪里找到client_id,以及如何设置praw.ini –

+1

更新了哪里可以找到'client_id' – ode2k

+0

非常感谢你的截图。它清楚地告诉我client_id在哪里:) –

相关问题