【发布时间】:2020-04-10 14:49:07
【问题描述】:
您好,我目前正在我的 django 服务器上使用 firebase admin sdk 来处理我的应用程序。我想检查用户是否是第一次在服务器端登录的用户。我想在 django 服务器上使用 firebase isNewUser() 但在 firebase admin sdk docs 中我没有看到任何相关信息。
我的服务器端从令牌中获取用户(从应用程序发送):
from utils.firebase_utils import auth
class FirebaseAuthentication(authentication.BaseAuthentication):
def authenticate(self, request):
token = request.META['HTTP_AUTHORIZATION']
if not token:
return None
try:
decoded_token = auth.verify_id_token(token)
uid = decoded_token['uid']
user = auth.get_user(uid, app=None)
# need to check if user first time log in too
except Exception as e:
raise exceptions.AuthenticationFailed('No such user')
return (user, None) # authentication successful
如何查看用户是否首次登录?
【问题讨论】:
标签: python django firebase firebase-authentication firebase-admin