Using Google for authentication
Just like we did for Facebook, we can integrate our application to enable login using Google.
Getting ready
We will start by building over the last recipe. It is easy to just implement Google authentication by leaving out the Facebook auth (by leaving out the Facebook-specific parts).
Now, we have to create a project from the Google developer console (https://console.developers.google.com). Then, we have to create a client ID for the web application; this ID will provide the credentials needed for OAuth to work. The following screenshot should help:
How to do it…
As always, we will first start with the configuration part in my_app/__init__.py
:
from flask_oauth import OAuth oauth = OAuth() google = oauth.remote_app('google', base_url='https://www.google.com/accounts/', authorize_url='https://accounts.google.com/o/oauth2/auth', request_token_url=None, request_token_params={ 'scope': 'https://www.googleapis.com/auth/userinfo.email', ...