o
    hc                     @   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)SocialToken)OAuth2AdapterOAuth2CallbackViewOAuth2LoginViewc                   @   s^   e Zd ZdZdZedd Zedd Zedd Zed	d
 Z	edd Z
defddZdS )AmazonCognitoOAuth2Adapteramazon_cognitoz8"DOMAIN" key is missing in Amazon Cognito configuration.c                 C   s   t j| ji S )N)r   	PROVIDERSgetprovider_idself r   k/var/www/html/pos/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_urltokenc                 K   sB   dd |ji}t  j| j|d}|  |  ||	 S )NAuthorizationz	Bearer {})headers)
r   r   r   get_requests_sessionr   r   raise_for_statusget_providersociallogin_from_responsejson)r   requestappr   kwargsr   
extra_datar   r   r   complete_login+   s   z)AmazonCognitoOAuth2Adapter.complete_loginN)__name__
__module____qualname__r   r   propertyr   r   r   r   r   r   r)   r   r   r   r   r      s    




r   N)allauth.socialaccountr   allauth.socialaccount.adapterr   allauth.socialaccount.modelsr   ,allauth.socialaccount.providers.oauth2.viewsr   r   r   r   adapter_viewoauth2_loginoauth2_callbackr   r   r   r   <module>   s    
,