
    f!                         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	m
Z
 d dlmZ d dlmZ d dlmZmZ  e j$                  e      Z G d	 d
      Z G d d      Z G d dee      Z G d de      Zy)    N)reverse)get_adapter)complete_social_loginrender_authentication_error)SocialLoginSocialToken)	AuthError)BaseLoginView)OAuthClient
OAuthErrorc                   *    e Zd ZeZd Zd Zd ZddZy)OAuthAdapterc                     || _         y N)request)selfr   s     f/var/www/cs2snipe.com/venv/lib/python3.12/site-packages/allauth/socialaccount/providers/oauth/views.py__init__zOAuthAdapter.__init__   s	        c                     t         )z0
        Returns a SocialLogin instance
        )NotImplementedError)r   r   apps      r   complete_loginzOAuthAdapter.complete_login   s
     "!r   c                     t        | j                        }|j                  | j                  | j                        }|j	                  | j                        S )N)provider)r   r   get_appprovider_idget_provider)r   adapterr   s      r   r   zOAuthAdapter.get_provider"   sA    dll+oodllT5E5EoF--r   Nc           
          | j                         }|j                  }i }|rdj                  |      |d<   | j                  ||j                  |j
                  | j                  | j                  |||      }|S )N scope)
parametersr   )r   r   joinclient_class	client_idsecretrequest_token_urlaccess_token_url)r   r   callback_urlr"   r   r   r#   clients           r   _get_clientzOAuthAdapter._get_client'   s{    $$&ll
"%((5/Jw""MMJJ""!!! # 	
 r   r   )	__name__
__module____qualname__r   r%   r   r   r   r,    r   r   r   r      s    L".
r   r   c                       e Zd Zed        Zy)	OAuthViewc                       fd}|S )Nc                 f            }| |_          |       |_         |j                  | g|i |S r   )r   r   dispatch)r   argskwargsr   r   clss       r   viewz$OAuthView.adapter_view.<locals>.view=   s8    5D"DL"7+DL 4==:4:6::r   r0   )r8   r   r9   s   `` r   adapter_viewzOAuthView.adapter_view;   s    	; r   N)r-   r.   r/   classmethodr:   r0   r   r   r2   r2   :   s     r   r2   c                       e Zd Zd Zy)OAuthLoginViewc                 :    | j                   j                         }|S r   )r   r   )r   r   s     r   r   zOAuthLoginView.get_providerG   s    <<,,.r   N)r-   r.   r/   r   r0   r   r   r=   r=   F   s    r   r=   c                       e Zd Zd Zy)OAuthCallbackViewc                    | j                   j                         }t        | j                   j                  dz         }| j                   j	                  ||      }|j                         sAd|j                  v rt        j                  }nt        j                  }t        ||||| d      S |j                  }	 |j                         }t        |d   |j                  dd            }|j                  r||_        | j                   j!                  ||||	      }	||	_        t%        j&                  |      |	_        t+        ||	      S # t,        $ r}
t        |||

      cY d}
~
S d}
~
ww xY w)z
        View to handle final steps of OAuth based authentication where the user
        gets redirected back to from the service provider
        	_callbackdenied)oauth_clientcallback_view)errorextra_contextoauth_tokenoauth_token_secret )tokentoken_secret)response)	exceptionN)r   r   r   r   r,   is_validGETr	   	CANCELLEDUNKNOWNr   r   get_access_tokenr   getpkr   rK   r   unstash_statestater   r   )r   r   r   login_done_urlr+   rF   r   access_tokenrK   logines              r   r5   zOAuthCallbackView.dispatchM   sO   
 <<,,. !9!9K!GH))'>B 7;;&!++!)).$*%)	  ll	O!224L"=1)--.BBGE
 vv	LL//el 0 E  EK%33G<EK(%88 	O.wANN	Os   7BE 	E'E"E'"E'N)r-   r.   r/   r5   r0   r   r   r@   r@   L   s    'Or   r@   )loggingdjango.urlsr   allauth.socialaccount.adapterr   allauth.socialaccount.helpersr   r   allauth.socialaccount.modelsr   r   .allauth.socialaccount.providers.base.constantsr	   *allauth.socialaccount.providers.base.viewsr
   ,allauth.socialaccount.providers.oauth.clientr   r   	getLoggerr-   loggerr   r2   r=   r@   r0   r   r   <module>rf      si      5 B D D 
		8	$! !H	 	Y (O	 (Or   