
    
                         d Z ddlmZmZ ddlZddlZddlmZmZm	Z	m
Z
mZmZmZ  ej                  e      Z G d de      Zd Zy)	zoauthlib.oauth2.rfc6749 ~~~~~~~~~~~~~~~~~~~~~~~

This module is an implementation of various logic needed
for consuming and providing OAuth 2.0 RFC6749.
    )absolute_importunicode_literalsN   )FatalClientErrorOAuth2ErrorServerErrorTemporarilyUnavailableErrorInvalidRequestErrorInvalidClientErrorUnsupportedTokenTypeErrorc                       e Zd Zd Zed        Zej                  d        Zed        Zej                  d        Zd Zd Z	d Z
y	)
BaseEndpointc                      d| _         d| _        y )NTF)
_available_catch_errorsselfs    9lib/third_party/oauthlib/oauth2/rfc6749/endpoints/base.py__init__zBaseEndpoint.__init__   s    DOD    c                     | j                   S Nr   r   s    r   	availablezBaseEndpoint.available   s    ??r   c                     || _         y r   r   )r   r   s     r   r   zBaseEndpoint.available   s	    DOr   c                     | j                   S r   r   r   s    r   catch_errorszBaseEndpoint.catch_errors!   s    r   c                     || _         y r   r   )r   r   s     r   r   zBaseEndpoint.catch_errors%   s
    %Dr   c                 6    |j                   st        |d      y)zRaise error on missing token.zMissing token parameter.)requestdescriptionN)tokenr
   r   r!   s     r   _raise_on_missing_tokenz$BaseEndpoint._raise_on_missing_token)   s#    =='AC C r   c                 F   | j                   j                  |      r>| j                   j                  |      s"t        j	                  d|       t        |      y| j                   j                  |j                  |      s"t        j	                  d|       t        |      y)z&Raise on failed client authentication.z!Client authentication failed, %r.r!   N)request_validatorclient_authentication_requiredauthenticate_clientlogdebugr   authenticate_client_id	client_idr$   s     r   _raise_on_invalid_clientz%BaseEndpoint._raise_on_invalid_client/   s    <<WE##77@		5w? 11 A ##::7$	ii3W=w//$r   c                     |j                   r>|j                   | j                  v r%|j                   | j                  vrt        |      yyy)zRaise on unsupported tokens.r'   N)token_type_hintvalid_token_typessupported_token_typesr   r$   s     r   _raise_on_unsupported_tokenz(BaseEndpoint._raise_on_unsupported_token:   sN    4#9#99t'A'AA%g66 	B 	: 	 r   N)__name__
__module____qualname__r   propertyr   setterr   r%   r/   r4    r   r   r   r      ss             & &C	07r   r   c                 B     t        j                          fd       }|S )Nc                 ~   | j                   s1t               }t        j                  d|z         i |j                  dfS | j
                  r	  | |g|i |S  | |g|i |S # t        $ r  t        $ r  t        $ r;}t               }t        j                  d|z         i |j                  dfcY d }~S d }~ww xY w)Nz*Endpoint unavailable, ignoring request %s.i  z.Exception caught while processing request, %s.i  )r   r	   r+   infojsonr   r   r   	Exceptionr   warning)endpointuriargskwargseerrorfs         r   wrapperz0catch_errors_and_unavailability.<locals>.wrapperD   s    
%
'a	hh;cAB_	#30000 x.t.v..    #DqHI5::s""#s   A& &B<0B71B<7B<)	functoolswraps)rG   rH   s   ` r   catch_errors_and_unavailabilityrK   B   s%    ??1/ /( 
.r   )__doc__
__future__r   r   rI   loggingerrorsr   r   r   r	   r
   r   r   	getLoggerr5   r+   objectr   rK   r:   r   r   <module>rR      sM   
 9  E E E g!,76 ,7^r   