Skip to content

Commit

Permalink
feat: add emulator script to create custom token
Browse files Browse the repository at this point in the history
  • Loading branch information
rorre committed Jun 2, 2024
1 parent 7936f0f commit 4a4cee5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions get_emulator_token.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os
from typing import cast
from firebase_admin import auth
import httpx
from cefies.internal.firestore import app

API_KEY = os.getenv("API_KEY", "")

try:
user = auth.get_user_by_email(email="[email protected]")
except:
user: auth.UserRecord = auth.create_user(email="[email protected]", password="sample")

custom_token = auth.create_custom_token(user.uid).decode()
response = httpx.post(
"http://localhost:9099/www.googleapis.com/identitytoolkit/v3/relyingparty/verifyCustomToken?key=" + API_KEY,
json={"token": custom_token, "returnSecureToken": True},
)


print(response.json())

0 comments on commit 4a4cee5

Please sign in to comment.