https://github.com/pj8912/flask-google-login
Login app using google OAuth in Flask
https://github.com/pj8912/flask-google-login
flask google-oauth2 login-system python3 sqlite3
Last synced: 9 months ago
JSON representation
Login app using google OAuth in Flask
- Host: GitHub
- URL: https://github.com/pj8912/flask-google-login
- Owner: pj8912
- Created: 2023-06-20T10:58:58.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-11T13:21:18.000Z (over 2 years ago)
- Last Synced: 2024-11-12T12:13:08.330Z (over 1 year ago)
- Topics: flask, google-oauth2, login-system, python3, sqlite3
- Language: Python
- Homepage: https://github.com/pj8912/flask-google-login
- Size: 15.6 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# flask-google-login
Register and Login with Google OAuth using Flask and SQLite
## Install requirements
```shell
pip install -r requirements.txt
```
---
> In google developer console create a project and
credentials
---
## Setup `.env` variables
Create a `.env`add these variables and their respective values :
- `APP_SECRET=` YOUR CLIENT SECRET
- `CLIENT_ID=` YOUR CLIENT ID
## Download Client Secret
- Download your `client secret` json file and rename it to `client_secret.json` and place it in the root folder of this app
## Create SQLite database
- Run
```
python created_db.py
```
to create your the sqlite databse `users.sqlite3` which will store the users on registration automatically.
## Add `/callback` URIs to Authorized URIs in google developer console
- 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`
## Start
```
$ python app.py
```
Open :
```
http://localhost:3000
```
## Working
- 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