For some time now I've been struggling with an OAuth authorisation. Every time I wanted to build console app that uses service secured be OAuth I had the same problem - how to provide user name and password without a browser. After some research I came up with an idea - I can use headless browser and Selenium to interact with it.
As it turned out my solution was extremely easy to implement and the basic prototype is less than 40 lines of code. Here's step-by-step guide for Python.
I'm using MacBook as my dev machine so I needed to install geckodriver that I will use later as a Selenium's Firefox driver.
For managing virtualenvs and packages I'm using pipenv.