Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

10
Am I getting my users' reddit accounts suspended by incorrectly managing their Oauth2 authentication flow? [PRAW]
Post Flair (click to view more posts with a particular flair)
Author Summary
AcesFullOfKings is in PRAW
Post Body

I run a web app which displays some subreddit statistics for a specific private subreddit. To view the webpage, you must be a member of the subreddit, so I wrote a very simple PRAW Bottle workflow for the user to log in. ALL I need is their username, which I check against a list of approved users. I am very unsure about using OAuth flow though, so I followed tutorials to get it working. The PRAW docs also aren't great so I may have made a mistake.

Here's my code flow authentication workflow:

  • User loads my site
  • The server checks their cookies: if they have a cookie containing a username, the page is served normally. Otherwise:
  • If they don't have a cookie, or it's not valid, they're redirected to PRAW's auth url using auth_url = r.auth.url(scopes=["identity"], state=state, duration='temporary'). state is randomly generated and is stored in a cookie. This only requests access to their account for the minimum of 1 hour.
  • At the auth_callback endpoint, I receive the code from reddit. The server checks the state cookie, and if it matches then it gets the code from the url using Bottle: code = request.query.get('code')

This is where I am uncertain about whether I'm making a mistake - given reddit's access code, I authorise it to get their account info:

access_token = r.auth.authorize(code)
username = str(r.user.me()) # this ^ logs out my PRAW session, so re-initialise the global bot object:
r = praw.Reddit(bot_account_name, redirect_uri=redirect_uri)

response.set_cookie('user_info', username, secret=global_key) # save the username in a cookie for the next visit

if username in allowed_users:
   # serve page normally
...

This workflow works fine, technically. However, since I implemented this a couple of months ago, several of my users have been temporarily or permanently suspended from reddit for no apparent reason. They've been told they're "evading subreddit bans" by using multiple accounts, and that they've violated reddit's TOS "multiple times". This seems to come as a complete surprise to them, out of nowhere - they say they've not even been to the subreddits they're supposedly banned from.

If this was just one or two users then I could chalk it to user error, but there have been several reports now so I'm thinking maybe I'm the common factor.

I think maybe where I'm doing r.auth.authorise(code), reddit considers this to be logging into their account? And since the server is "logging into" everyone's account from the same IP address, maybe reddit thinks that there is account-sharing going on??

I have never done ANY web development before this, so I may well have made some mistake with the oauth or cookies workflow.

Or, am I overthinking this and my users' account problems are nothing to do with me? Has anyone else noticed an uptick in weird user suspensions in the last couple of months?

Author
Account Strength
100%
Account Age
11 years
Verified Email
Yes
Verified Flair
No
Total Karma
36,528
Link Karma
25,172
Comment Karma
10,932
Profile updated: 6 days ago

Subreddit

Post Details

Location
We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
1 year ago