Register and Login with Google OAuth using Flask and SQLite
pip install -r requirements.txt
In google developer console create a project and credentials
Create a .env
add these variables and their respective values :
APP_SECRET=
YOUR CLIENT SECRETCLIENT_ID=
YOUR CLIENT ID
- Download your
client secret
json file and rename it toclient_secret.json
and place it in the root folder of this app
- Run
python created_db.py
to create your the sqlite databse users.sqlite3
which will store the users on registration automatically.
-
The app runs on
http://localhost:3000
-
I use two different routes for login and registration
-
In you
Authorized URIs
section add these following two URIs-
http://localhost:300/callback
-
http://localhost:3000/login/callback
and click
SAVE
-
$ python app.py
Open :
http://localhost:3000
-
Seperate flows for registration and login
-
On registration, the user's google username, password and the oauthId which is unique per user is stored in the database and redirected to home
-
On login, the process takes flow and checks the email that is used for login is already in the database and creates a session redirecting to home where you can see a welcome message and logout link, or it will simply redirect to home