With this blog post I hope to provide some help to those who are trying to combine Miguel Grinberg’s Flask Mega Tutorial with his other tutorial titled OAuth Authentication with Flask. I have a repo that has a working version of his Mega Tutorial through chapter 5 that uses OAuth instead of OpenID. You can find it here https://github.com/JasonMFry/Flask-Mega-Tutorial-With-OAuth (there are known bugs that will occur as you move further into the Mega Tutorial, and I will list them in the github issues). I have made some comments in the code that help explain why some code needs to be changed. And for reference I have commented out (instead of deleted) all OpenID references that are no longer needed.
As a quick and brief explanation, the code in
flask-oauth-example/app.py (from his OAuth tutorial) gets divided up into
app/views.py (from his Mega Tutorial). The
oauth.py file (from OAuth tutorial) goes directly into the
app/ directory. The code in
flask-oauth-example/templates/index.html (from OAuth tutorial) replaces most of the code in
app/templates/login.html (from Mega Tutorial). Your directory structure will look like this:
| | |____base.html
| | |____index.html
| | |____login.html
You will also have a db_repository directory but that was adding unnecessary info to the above directory structure so I removed it. But I mention this so you don’t get confused. I hope you are able to follow his two tutorials, and compare your code to mine to get yours working. Good luck, and sound off in the comments below if you need some help.