o
    Lf
                     @   sn   d dl mZ d dlmZ d dlmZmZ d dlmZ G dd de	Z
G dd deZG d	d
 d
eZegZdS )    )EmailAddress)QUERY_EMAIL)
AuthActionProviderAccount)OAuth2Providerc                   @   s   e Zd ZdZdZdS )ScopeemailprofileN)__name__
__module____qualname__EMAILPROFILE r   r   p/var/www/html/humari/django-venv/lib/python3.10/site-packages/allauth/socialaccount/providers/google/provider.pyr      s    r   c                       s0   e Zd ZdZdd Zdd Z fddZ  ZS )GoogleAccounta  
    The account data can be in two formats. One, originating from
    the /v2/userinfo endpoint:

        {'email': 'john.doe@gmail.com',
         'given_name': 'John',
         'id': '12345678901234567890',
         'locale': 'en',
         'name': 'John',
         'picture': 'https://lh3.googleusercontent.com/a/code',
         'verified_email': True}

    The second, which is the payload of the id_token:

        {'at_hash': '-someHASH',
         'aud': '123-pqr.apps.googleusercontent.com',
         'azp': '123-pqr.apps.googleusercontent.com',
         'email': 'john.doe@gmail.com',
         'email_verified': True,
         'exp': 1707297277,
         'given_name': 'John',
         'iat': 1707293677,
         'iss': 'https://accounts.google.com',
         'locale': 'en',
         'name': 'John',
         'picture': 'https://lh3.googleusercontent.com/a/code',
         'sub': '12345678901234567890'}
    c                 C      | j jdS )Nlinkaccount
extra_datagetselfr   r   r   get_profile_url*      zGoogleAccount.get_profile_urlc                 C   r   )Npicturer   r   r   r   r   get_avatar_url-   r   zGoogleAccount.get_avatar_urlc                    s   t t|  }| jjd|S )Nname)superr   to_strr   r   r   )r   dflt	__class__r   r   r    0   s   zGoogleAccount.to_str)r
   r   r   __doc__r   r   r    __classcell__r   r   r"   r   r      s
    r   c                       sH   e Zd ZdZdZeZdd Z fddZdd Z	d	d
 Z
dd Z  ZS )GoogleProvidergoogleGooglec                 C   s   t jg}tr|t j |S )N)r   r   r   appendr   )r   scoper   r   r   get_default_scope:   s   z GoogleProvider.get_default_scopec                    s(   t t| ||}|tjkrd|d< |S )Nzselect_account consentprompt)r   r&   get_auth_paramsr   REAUTHENTICATE)r   requestactionretr"   r   r   r-   @   s   
zGoogleProvider.get_auth_paramsc                 C   s   d|v r|d S |d S )Nsubidr   r   datar   r   r   extract_uidF   s   zGoogleProvider.extract_uidc                 C   s    t |d|d|ddS )Nr   family_name
given_name)r   	last_name
first_name)dictr   r4   r   r   r   extract_common_fieldsK   s
   z$GoogleProvider.extract_common_fieldsc                 C   sB   g }| d}|rt| dp| d}|t||dd |S )Nr   email_verifiedverified_emailT)r   verifiedprimary)r   boolr)   r   )r   r5   r1   r   r?   r   r   r   extract_email_addressesR   s   
z&GoogleProvider.extract_email_addresses)r
   r   r   r3   r   r   account_classr+   r-   r6   r<   rB   r%   r   r   r"   r   r&   5   s    r&   N)allauth.account.modelsr   "allauth.socialaccount.app_settingsr   $allauth.socialaccount.providers.baser   r   /allauth.socialaccount.providers.oauth2.providerr   objectr   r   r&   provider_classesr   r   r   r   <module>   s    )
&