o
    h                     @   s   d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d d	lmZ e eZG d
d deZdS )    N)	parse_qsl)ImproperlyConfigured)reverse)	urlencode)render_authentication_error)Provider)
AuthAction)
OAuthErrorc                       sj   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Z fddZdddZ  ZS )OAuthProviderTc                 K   s&   t | jd }|r|d t| }|S )N_login?)r   idr   )selfrequestkwargsurl r   e/var/www/html/pos/venv/lib/python3.10/site-packages/allauth/socialaccount/providers/oauth/provider.pyget_login_url   s   zOAuthProvider.get_login_urlc                 C   s   |   }t|di }|S )NAUTH_PARAMS)get_settingsdictget)r   settingsretr   r   r   get_auth_params   s   zOAuthProvider.get_auth_paramsc                 C   s0   |   }|jdd }|r|tt| |S )Nauth_params)r   GETr   updater   r   )r   r   actionr   dynamic_auth_paramsr   r   r   get_auth_params_from_request   s
   z*OAuthProvider.get_auth_params_from_requestc                 C   s   d S Nr   )r   r   r   r   r   r   get_auth_url&   s   zOAuthProvider.get_auth_urlc                 C   s   |   S r"   )	get_scoper   r   r   r   r   get_scope_from_request,   s   z$OAuthProvider.get_scope_from_requestc                 C   s&   |   }|d}|d u r|  }|S )NSCOPE)r   r   get_default_scope)r   r   scoper   r   r   r$   /   s
   
zOAuthProvider.get_scopec                 C   s   g S r"   r   )r   r   r   r   r(   6   s   zOAuthProvider.get_default_scopec                 C   s"   t | dstd| | |S )Noauth_adapter_classzNo oauth_adapter_class set for )hasattrr   r*   r%   r   r   r   get_oauth_adapter9   s   

zOAuthProvider.get_oauth_adapterc                    sF   t  |}| ||d< |jdtj}||d< | |||d< |S )Nr)   r   r   )super get_redirect_from_request_kwargsr&   r   r   r   AUTHENTICATEr!   )r   r   r   r   	__class__r   r   r.   >   s   z.OAuthProvider.get_redirect_from_request_kwargsNc              
   K   s   t | jd }| |}|dtj}| ||p|j}	|dd }
|
d u r*|  }
|dd }|d u r8| 	 }| j
||||fi | |j|||d}z||	|
W S  tys } ztjddd t|| |d	W  Y d }~S d }~ww )
N	_callbackr   r   r)   )r)   zOAuth authentication errorT)exc_info)	exception)r   r   r,   popr   r/   r#   authorize_urlr   r$   stash_redirect_state_get_clientget_redirectr	   loggererrorr   )r   r   processnext_urldatar   callback_urloauth_adapterr   auth_urlr   r)   clienter   r   r   redirectF   s&   
zOAuthProvider.redirect)NN)__name__
__module____qualname__supports_redirectr   r   r!   r#   r&   r$   r(   r,   r.   rD   __classcell__r   r   r0   r   r
      s    r
   )loggingurllib.parser   django.core.exceptionsr   django.urlsr   django.utils.httpr   allauth.socialaccount.helpersr   $allauth.socialaccount.providers.baser   .allauth.socialaccount.providers.base.constantsr   ,allauth.socialaccount.providers.oauth.clientr	   	getLoggerrE   r:   r
   r   r   r   r   <module>   s    
