As some of you may know "Google Sign-in with web" will be deprecated on March 31, 2023. I have done a new "Sign in with Google for web" on my application. It works very smoothly and is easy to implement.
- Follow the steps described in Setup to configure your OAuth Consent Screen and to obtain a Client ID.
- Load the client library.
- Set your Google client id as a environment variable GOOGLE_CLIENT_ID
Follow instructions to install the latest version of python for your platform in the python docs
We recommend working within a virtual environment whenever using Python for projects. This keeps your dependencies for each project separate and organaized. Instructions for setting up a virual enviornment for your platform can be found in the python docs
Once you have your virtual environment setup and running, install dependencies by running:
pip install -r requirements.txt
This will install all of the required packages we selected within the requirements.txt
file.
-
Flask is a lightweight backend microservices framework. Flask is required to handle requests and responses.
-
To validate an ID token in Python, use the verify_oauth2_token
From within the directory first ensure you are working using your created virtual environment.
Each time you open a new terminal session, run:
export FLASK_APP=app.py;
To run the server, execute:
flask run --reload
The --reload
flag will detect file changes and restart the server automatically.
Get Client Details
GET '/login'
- Fetches all informations about client: id, name, email, family_name.
- Request Arguments: None
- Returns: An object owners with all the cleint detail.
- "localhost:8000/login"
- {
"data": {
"aud": "CLIENT_ID",
"azp": "CLIENT_ID",
"email": "CLIENT_ EMAIL",
"email_verified": true,
"exp": 1678661244,
"family_name": "....",
"given_name": "....",
"iat": ,
"iss": "https://accounts.google.com",
"jti": " ",
"name": "Purvi Rawal",
"nbf": ,
"picture": " ",
"sub": " "
}
}
Purvi Rawal