1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Flask: Google でログイン

Last updated at Posted at 2023-08-14

こちらのページと同じことを、Arch Linux で行いました。
Create a Flask Application With Google Login

コードは、zip でダウンロードできます。

materials-flask-google-login.zip

client_id を作成

次を入れて下さい

承認済みの JavaScript 生成元

https://127.0.0.1:5000

承認済みのリダイレクト URI

https://127.0.0.1:5000/login/callback

image.png

必要なライブラリーのインストール

sudo pacman -S python-flask
sudo pacman -S python-flask-login
sudo pacman -S python-pyopenssl

コードを解凍

unzip materials-flask-google-login.zip
$ tree
.
├── Pipfile
├── Pipfile.lock
├── README.md
├── app.py
├── db.py
├── requirements.txt
├── schema.sql
└── user.py

データベースの初期化

$ python app.py
Initialized the database.

サーバーの実行

実行スクリプト

export GOOGLE_CLIENT_ID="371868132900-e******.apps.googleusercontent.com"
export GOOGLE_CLIENT_SECRET="GOCSPX-J1YsuHlu*******"
export SECRET_KEY="hello"
python app.py

実行

$ ./server.sh 
 * Serving Flask app 'app'
 * Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on https://127.0.0.1:5000
Press CTRL+C to quit

クライアントでアクセス

https://127.0.0.1:5000/
image.png

Advanced をクリック

image.png

Proceed to 127.0.0.1 (unsafe) をクリック

image.png

Google Login をクリック

image.png

Gmail のアドレスでログイン

image.png

確認したバージョン

$ python --version
Python 3.11.3

$ flask --version
Python 3.11.3
Flask 2.2.5
Werkzeug 2.3.2
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?