Your code is very needlessly over-complicated just to login with PRAW. The way reccomended in the documentation is to have reddit = praw.Reddit('SOME-NAME-HERE') to login. Then, in your praw.ini file, set it up to look like this:

[DEFAULT] # A boolean to indicate whether or not to check for package updates. check_for_updates=True # Object to kind mappings comment_kind=t1 message_kind=t4 redditor_kind=t2 submission_kind=t3 subreddit_kind=t5 # The URL prefix for OAuth-related requests. oauth_url=https://oauth.reddit.com # The URL prefix for regular requests. reddit_url=https://www.reddit.com # The URL prefix for short URLs. short_url=https://redd.it [SOME-NAME-HERE] user_agent=USER-AGENT-HERE username=REDDIT-ACCOUNT-USERNAME password=REDDIT-ACCOUNT-PASSWORD client_id=REDDIT-APP-CLIENT-ID client_secret=REDDIT-APP-CLIENT-SECRET

Requirements for the user agent are found here:

Change your client's User-Agent string to something unique and descriptive, including the target platform, a unique application identifier, a version string, and your username as contact information, in the following format: <platform>:<app ID>:<version string> (by /u/<reddit username>)

- Example: User-Agent: android:com.example.myredditapp:v1.2.3 (by /u/kemitche)

Many default User-Agents (like "Python/urllib" or "Java") are drastically limited to encourage unique and descriptive user-agent strings.

Including the version number and updating it as you build your application allows us to safely block old buggy/broken versions of your app.

NEVER lie about your user-agent. This includes spoofing popular browsers and spoofing other bots. We will ban liars with extreme prejudice.

If you have any future questions dont hesitate to ask them as a comment to this answer!