get ( "FN_CLIENT_ID", default = False ) CLIENT_SECRET = os. get ( "FN_BASE_URI", default = False ) CLIENT_ID = os. get ( "FN_AUTH_REDIRECT_URI", default = False ) BASE_URI = os. Import functools import os import flask from authlib.client import OAuth2Session import import googleapiclient.discovery ACCESS_TOKEN_URI = '' AUTHORIZATION_URL = '' AUTHORIZATION_SCOPE = 'openid email profile' AUTH_REDIRECT_URI = os. For this example, there’s no special reason to use Authlib instead of google-auth the only reason I used Authlib is because I found the Authlib documentation easier to follow than google-auth.Īdd a file with requirements.txt with the following: We’ll be using Authlib as an alternative to the deprecated oauth2client. Google Authentication with Python and Flask Copy these, and store them somewhere safe. For this app, we’ll be running on localhost, port 8040, and redirecting to /google/auth, so our redirect URI will be Once you’re done, click Create, and you’ll be presented with a dialog with our OAuth Client ID and Client Secret. Navigate to the Google API console and select the option to create a new set of OAuth credentials: Make sure you have the following before you start: Security is a big topic, and the advice this blog post doesn’t come with any warranty or guarantees. After spending a fair amount of time trying to get it working, I was surprised to find that oauth2client is deprecated, and not recommended for use.
0 Comments
Leave a Reply. |