PRAW:使用 OAuth 授权使我无法获得 submissions/comments
PRAW: Authorizing with OAuth prevents me from getting submissions/comments
如果我使用 OAuth,我无法从 subreddit 获得新的提交或评论。
我的 Oauth 代码如下所示:
import praw
import webbrowser
r = praw.Reddit(user_agent)
r.set_oauth_app_info(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI)
authURL = r.get_authorize_url("FUZZYPICKLES", "identity submit", True)
webbrowser.open(authURL)
authCode = input("Enter the code: ")
accInfo = r.get_access_information(authCode)
之后我可以尝试获得提交
submission = r.get_subreddit("test").get_new()
或评论
comments = r.get_comments("test")
但是如果我使用任何一个值,程序就会崩溃并出现错误:
raise OAuthInsufficientScope('insufficient_scope', response.url)
praw.errors.OAuthInsufficientScope: insufficient_scope on url https://oauth.reddit.com/r/test/comments/.json
如果我不使用 OAuth,无论是使用 login()
还是不授权,我都不会遇到这样的问题。我正在使用 Python 3.4。我做错了什么?
我自己找到了解决方案。要阅读帖子,您的请求范围列表中需要 "read"。所以,"identity submit"
应该是 "identity read submit"
.
如果我使用 OAuth,我无法从 subreddit 获得新的提交或评论。
我的 Oauth 代码如下所示:
import praw
import webbrowser
r = praw.Reddit(user_agent)
r.set_oauth_app_info(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI)
authURL = r.get_authorize_url("FUZZYPICKLES", "identity submit", True)
webbrowser.open(authURL)
authCode = input("Enter the code: ")
accInfo = r.get_access_information(authCode)
之后我可以尝试获得提交
submission = r.get_subreddit("test").get_new()
或评论
comments = r.get_comments("test")
但是如果我使用任何一个值,程序就会崩溃并出现错误:
raise OAuthInsufficientScope('insufficient_scope', response.url)
praw.errors.OAuthInsufficientScope: insufficient_scope on url https://oauth.reddit.com/r/test/comments/.json
如果我不使用 OAuth,无论是使用 login()
还是不授权,我都不会遇到这样的问题。我正在使用 Python 3.4。我做错了什么?
我自己找到了解决方案。要阅读帖子,您的请求范围列表中需要 "read"。所以,"identity submit"
应该是 "identity read submit"
.