o
    Lf                     @   s`   d dl mZ d dlmZ d dlmZ d dlmZmZm	Z	 G dd deZ
e	e
Zee
ZdS )    )app_settings)get_adapter)AmazonCognitoProvider)OAuth2AdapterOAuth2CallbackViewOAuth2LoginViewc                   @   sZ   e Zd ZejZdZedd Zedd Z	edd Z
edd	 Zed
d Zdd ZdS )AmazonCognitoOAuth2Adapterz8"DOMAIN" key is missing in Amazon Cognito configuration.c                 C   s   t j| ji S )N)r   	PROVIDERSgetprovider_idself r   u/var/www/html/humari/django-venv/lib/python3.10/site-packages/allauth/socialaccount/providers/amazon_cognito/views.pysettings   s   z#AmazonCognitoOAuth2Adapter.settingsc                 C   s"   | j d}|d u rt| j|S )NDOMAIN)r   r
   
ValueErrorDOMAIN_KEY_MISSING_ERROR)r   domainr   r   r   r      s   
z!AmazonCognitoOAuth2Adapter.domainc                 C      d | jS )Nz{}/oauth2/tokenformatr   r   r   r   r   access_token_url!      z+AmazonCognitoOAuth2Adapter.access_token_urlc                 C   r   )Nz{}/oauth2/authorizer   r   r   r   r   authorize_url%   r   z(AmazonCognitoOAuth2Adapter.authorize_urlc                 C   r   )Nz{}/oauth2/userInfor   r   r   r   r   profile_url)   r   z&AmazonCognitoOAuth2Adapter.profile_urlc                 K   s@   dd |i}t  j| j|d}|  |  || S )NAuthorizationz	Bearer {})headers)	r   r   get_requests_sessionr
   r   raise_for_statusget_providersociallogin_from_responsejson)r   requestappaccess_tokenkwargsr   
extra_datar   r   r   complete_login-   s   
z)AmazonCognitoOAuth2Adapter.complete_loginN)__name__
__module____qualname__r   idr   r   propertyr   r   r   r   r   r(   r   r   r   r   r      s    




r   N)allauth.socialaccountr   allauth.socialaccount.adapterr   7allauth.socialaccount.providers.amazon_cognito.providerr   ,allauth.socialaccount.providers.oauth2.viewsr   r   r   r   adapter_viewoauth2_loginoauth2_callbackr   r   r   r   <module>   s    
,