o a@sRdZddlZddlmZddlmZddlmZmZe e Z 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)utils) BaseEndpointcatch_errors_and_unavailabilityc@sheZdZdZdZddZeddZeddZed d Z ed d Z e   dddZ ddZ dS) TokenEndpointaToken issuing endpoint. The token endpoint is used by the client to obtain an access token by presenting its authorization grant or refresh token. The token endpoint is used with every authorization grant except for the implicit grant type (since an access token is issued directly). The means through which the client obtains the location of the token endpoint are beyond the scope of this specification, but the location is typically provided in the service documentation. The endpoint URI MAY include an "application/x-www-form-urlencoded" formatted (per `Appendix B`_) query component, which MUST be retained when adding additional query parameters. The endpoint URI MUST NOT include a fragment component:: https://example.com/path?query=component # OK https://example.com/path?query=component#fragment # Not OK Since requests to the token endpoint result in the transmission of clear-text credentials (in the HTTP request and response), the authorization server MUST require the use of TLS as described in Section 1.6 when sending requests to the token endpoint:: # We will deny any request which URI schema is not with https The client MUST use the HTTP "POST" method when making access token requests:: # HTTP method is currently not enforced Parameters sent without a value MUST be treated as if they were omitted from the request. The authorization server MUST ignore unrecognized request parameters. Request and response parameters MUST NOT be included more than once:: # Delegated to each grant type. .. _`Appendix B`: https://tools.ietf.org/html/rfc6749#appendix-B )POSTcCs t|||_||_||_dSN)r__init__ _grant_types_default_token_type_default_grant_type)selfdefault_grant_typedefault_token_type grant_typesrI/usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/endpoints/token.pyr ?s  zTokenEndpoint.__init__cC|jSr )r rrrrrEzTokenEndpoint.grant_typescCrr )r rrrrrIrz TokenEndpoint.default_grant_typecCs|j|jSr )rgetrrrrrdefault_grant_type_handlerMsz(TokenEndpoint.default_grant_type_handlercCrr )r rrrrrQrz TokenEndpoint.default_token_typerNc Csrt||||d}||t|j|_||_|r||_|r!||_|j |j|j } t d|j| | ||jS)z7Extract grant_type and route to the designated handler.) http_methodbodyheadersz(Dispatching grant_type %s request to %r.)rvalidate_token_requestr scope_to_listscopescopesextra_credentials grant_typeclaimsrrrlogdebugcreate_token_responser) rurirrr credentialsgrant_type_for_scoper"requestgrant_type_handlerrrrr%Us&  z#TokenEndpoint.create_token_responsecCs||||dSr )_raise_on_bad_method_raise_on_bad_post_request)rr)rrrrus z$TokenEndpoint.validate_token_request)rNNNNN)__name__ __module__ __qualname____doc__valid_request_methodsr propertyrrrrrr%rrrrrrs$)     r) r0loggingoauthlib.commonroauthlib.oauth2.rfc6749rbaserr getLoggerr-r#rrrrrs