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 3 years have passed since last update.

Python3: Firebase Auth のトークンの作成

Last updated at Posted at 2021-02-06

次の記事を参考にしました。
PythonでFirebase Authenticationのトークン取得とFastAPIでトークン検証
参考ページ
Relyingparty: verifyPassword

get_token.py
#! /usr/bin/python
# -*- coding: utf-8 -*-
#
#	get_token.py
#
#					Feb/06/2021
#
# ----------------------------------------------------------------
import sys
import os
import  requests
from dotenv import load_dotenv
# ----------------------------------------------------------------
sys.stderr.write("*** 開始 ***\n")
email = sys.argv[1]
password = sys.argv[2]

sys.stderr.write("email = " + email + "\n")
sys.stderr.write("password = " + password + "\n")

dotenv_path = '.env'
load_dotenv(dotenv_path)

api_key = os.environ.get("API_KEY")
uri = f"https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key={api_key}"
data = {"email": email, "password": password, "returnSecureToken": True}

result = requests.post(url=uri, data=data).json()

token = result['idToken']

print(token)
sys.stderr.write("*** 終了 ***\n")
# ----------------------------------------------------------------
.env
API_KEY = "AIzaS....."

実行スクリプト

./get_token.py ppp@example.com hello888 > token01.txt
./get_token.py qqq@example.com hello999 > token02.txt

関連ページ
Node.js: Firebase Auth のトークンの作成

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?