o a @sFdZddlZddlmZddlmZmZeeZ GdddeZ dS)z oauthlib.oauth2.rfc6749 ~~~~~~~~~~~~~~~~~~~~~~~ This module is an implementation of various logic needed for consuming and providing OAuth 2.0 RFC6749. N)Request) BaseEndpointcatch_errors_and_unavailabilityc@sVeZdZdZddZeddZeddZedd Ze dd d Z ddZ d S)ResourceEndpointaAuthorizes access to protected resources. The client accesses protected resources by presenting the access token to the resource server. The resource server MUST validate the access token and ensure that it has not expired and that its scope covers the requested resource. The methods used by the resource server to validate the access token (as well as any error responses) are beyond the scope of this specification but generally involve an interaction or coordination between the resource server and the authorization server:: # For most cases, returning a 403 should suffice. The method in which the client utilizes the access token to authenticate with the resource server depends on the type of access token issued by the authorization server. Typically, it involves using the HTTP "Authorization" request header field [RFC2617] with an authentication scheme defined by the specification of the access token type used, such as [RFC6750]:: # Access tokens may also be provided in query and body https://example.com/protected?access_token=kjfch2345sdf # Query access_token=sdf23409df # Body cCst|||_||_dSN)r__init___tokens_default_token)self default_token token_typesrL/usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/endpoints/resource.pyr,s  zResourceEndpoint.__init__cC|jSr)r r rrrr 1zResourceEndpoint.default_tokencCs|j|jSr)tokensgetr rrrrdefault_token_type_handler5sz+ResourceEndpoint.default_token_type_handlercCrr)r rrrrr9rzResourceEndpoint.tokensGETNcCsPt||||}|||_||_|j|j|j}td|j|| ||fS)z0Validate client, code etc, return body + headersz(Dispatching token_type %s request to %r.) rfind_token_type token_typescopesrrrlogdebugvalidate_request)r uri http_methodbodyheadersrrequesttoken_type_handlerrrrverify_request=s  zResourceEndpoint.verify_requestcs8tfdd|jDdd}t|r|ddSdS)a>Token type identification. RFC 6749 does not provide a method for easily differentiating between different token types during protected resource access. We estimate the most likely token type (if any) by asking each known token type to give an estimation based on the request. c3s"|] \}}||fVqdSr) estimate_type).0ntr!rr Rsz3ResourceEndpoint.find_token_type..T)reverserrN)sortedritemslen)r r! estimatesrr(rrJs z ResourceEndpoint.find_token_type)rNNN) __name__ __module__ __qualname____doc__rpropertyr rrrr#rrrrrrs    r) r2loggingoauthlib.commonrbaserr getLoggerr/rrrrrrs