To log in with Facebook and Twitter, the OAuth protocol is used as previously described. Our app will not use OAuth directly; instead, another Flask extension will be used, named Flask Dance. In the requirements.txt, enter the following:
...
flask-dance
...
As previously described, the OAuth protocol needs a previously created application in each provider's developer page. After our application is created, we will have a key and secret token for each provider. For now, we are going to keep these credentials on the configuration file as is. Later, we will be using environment variables to handle them. So, in the configuration file config.py, add the following:
...
class Config(object):
...
TWITTER_API_KEY = "XXX"
TWITTER_API_SECRET = "XXXX"
FACEBOOK_CLIENT_ID = "YYYY"
FACEBOOK_CLIENT_SECRET = "YYYY"
Now we are ready...