How, What and Why?ΒΆ

prawoauth2 comes with two components, PrawOAuth2Mini and PrawOAuth2Server. PrawOAuth2Server authorizes your app/script with the Reddit account and gives you access token. PrawOAuth2Mini uses these tokens for all next transactions with Reddit. Remember, for a bot, you only need a valid refresh_token so it can refresh the expired access_token.

Why it is written like that? If you are writing a bot and running it on a headless server, something like Amazon AWS or Openshift, you cannot authorize your script with the Reddit account, as it tries to open the browser for authorization. This is one time only operation(if you pass the parameter permanent). So, I decided to break this into two parts. Run the PrawOAuth2Server locally on your computer, get the access_token, refresh_token and save them somewhere (in a very secret place). Later, PrawOAuth2Mini can make use of these tokens for further transactions. And it does not require browser at all, so that it can run in a headless server without any hiccups.

TLDR; PrawOAuth2Server meant to be run only once locally on your main machine to fetch the first access_token, refresh_token and PrawOAuth2Mini later and for everything.