o
    ,lHf                     @   s   d dl Z d dlZd dlmZ d dlmZ d dlmZmZ d dlm	Z	 d dl
mZ ejs5edZeeZG dd	 d	ejZdS )
    N)auth)credentials)authentication
exceptions)User)timezonez./serviceAccountKey.jsonc                   @   s   e Zd Zdd ZdS )FirebaseAuthenticationc                 C   s   |j d}|s		 |d }d }zt|}W n	 ty"   Y nw |r'|s)d S z|d}W n	 ty9   Y nw tjj	|d\}}|d fS )NHTTP_AUTHORIZATION uid)username)
METAgetsplitpopfirebase_authZverify_id_token	Exceptionr   objectsget_or_create)selfrequestauth_headerZid_tokenZdecoded_tokenr   usercreated r   E/Users/leeseokho/Desktop/Study/Cat_ch/server/cat_ch/authentication.pyauthenticate   s&   z#FirebaseAuthentication.authenticateN)__name__
__module____qualname__r   r   r   r   r   r      s    r   )osZfirebase_adminr   r   r   rest_frameworkr   r   django.contrib.auth.modelsr   django.utilsr   Z_appsCertificateZcredZinitialize_appZdefault_appBaseAuthenticationr   r   r   r   r   <module>   s    

