a \`"@s\dZddlZddlZddlmZmZmZmZmZm Z m Z e e Z GdddZddZdS) z oauthlib.oauth2.rfc6749 ~~~~~~~~~~~~~~~~~~~~~~~ This module is an implementation of various logic needed for consuming and providing OAuth 2.0 RFC6749. N)FatalClientErrorInvalidClientErrorInvalidRequestError OAuth2Error ServerErrorTemporarilyUnavailableErrorUnsupportedTokenTypeErrorc@seZdZddZeddZejddZeddZejddZed d Zejd d Zd d Z ddZ ddZ ddZ ddZ dS) BaseEndpointcCsd|_d|_d|_dS)NTF) _available _catch_errors_valid_request_methodsselfrJ/usr/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/endpoints/base.py__init__szBaseEndpoint.__init__cCs|jSNr rrrrvalid_request_methodssz"BaseEndpoint.valid_request_methodscCs |durdd|D}||_dS)NcSsg|] }|qSr)upper).0xrrr !z6BaseEndpoint.valid_request_methods..r)rrrrrrscCs|jSrr rrrr available%szBaseEndpoint.availablecCs ||_dSrr)rrrrrr)scCs|jSrr rrrr catch_errors-szBaseEndpoint.catch_errorscCs ||_dSrr)rrrrrr1scCs|jst|dddS)zRaise error on missing token.zMissing token parameter.request descriptionN)tokenrrr rrr_raise_on_missing_token5sz$BaseEndpoint._raise_on_missing_tokencCsZ|j|r0|j|sVtd|t|dn&|j|j|sVtd|t|ddS)z&Raise on failed client authentication.z!Client authentication failed, %r.r N)Zrequest_validatorZclient_authentication_requiredZauthenticate_clientlogdebugrZauthenticate_client_idZ client_idr#rrr_raise_on_invalid_client:s     z%BaseEndpoint._raise_on_invalid_clientcCs,|jr(|j|jvr(|j|jvr(t|ddS)zRaise on unsupported tokens.r%N)Ztoken_type_hintZvalid_token_typesZsupported_token_typesr r#rrr_raise_on_unsupported_tokenDs   z(BaseEndpoint._raise_on_unsupported_tokencCs<|jdurtd|j|jvr8t|d|jddS)Nz0Configure "valid_request_methods" property firstzUnsupported request method %sr)r ValueError http_methodrrr#rrr_raise_on_bad_methodKs   z!BaseEndpoint._raise_on_bad_methodcCs,|jdkr(|jpd}|r(t|dddS)z/Raise if invalid POST request received ZPOSTz$URL query parameters are not allowedrN)r+rZ uri_queryr)rr Z query_paramsrrr_raise_on_bad_post_requestRs  z'BaseEndpoint._raise_on_bad_post_requestN)__name__ __module__ __qualname__rpropertyrsetterrrr$r(r)r,r.rrrrr s$       r cstfdd}|S)Nc s|js&t}td|i|jdfS|jrz||g|Ri|WStyZYqtylYqty}z,t }t d|i|jdfWYd}~Sd}~00n||g|Ri|SdS)Nz*Endpoint unavailable, ignoring request %s.iz.Exception caught while processing request, %s.i) rrr&infoZjsonrrr ExceptionrZwarning)ZendpointZuriargskwargseerrorfrrwrapper\s$   $z0catch_errors_and_unavailability..wrapper) functoolswraps)r;r<rr:rcatch_errors_and_unavailability[sr?)__doc__r=Zloggingerrorsrrrrrrr Z getLoggerr/r&r r?rrrrs $ H