简体   繁体   中英

How do I avoid login for messaging Using Python Praw script?

I have written a script to archive submissions and comments of a certain author on Reddit. When it detects a new post I have it pm me the content.

Currently I start the session like this...

client = praw.Reddit(user_agent=USER_AGENT)
client.set_oauth_app_info(client_id = CLIENT_ID, client_secret = CLIENT_SECRET, redirect_uri="http://127.0.0.1:65010/authorize_callback")
 #log in for messaging
client.login(MY_USERNAME, MY_PASSWORD)

I see that using login is deprecated. What steps do I need to take to give my script permission to "privatemessage"? All the examples I can find use login and I am stumped.

You need the privatemessages OAuth Scope.
Use it as a string in get_authorize_url() , as shown here: https://praw.readthedocs.io/en/stable/pages/oauth.html#step-3-getting-authorization-from-the-user

List of all possible Scopes: https://praw.readthedocs.io/en/stable/pages/oauth.html#oauth-scopes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM