;idZddlZddlZddlZddlZddlmZGddejZGdde Z Gdd ej Z d Z dS) a'OAuth 2.0 Utilities. This module provides implementations for various OAuth 2.0 utilities. This includes `OAuth error handling`_ and `Client authentication for OAuth flows`_. OAuth error handling -------------------- This will define interfaces for handling OAuth related error responses as stated in `RFC 6749 section 5.2`_. This will include a common function to convert these HTTP error responses to a :class:`google.auth.exceptions.OAuthError` exception. Client authentication for OAuth flows ------------------------------------- We introduce an interface for defining client authentication credentials based on `RFC 6749 section 2.3.1`_. This will expose the following capabilities: * Ability to support basic authentication via request header. * Ability to support bearer token authentication via request header. * Ability to support client ID / secret authentication via request body. .. _RFC 6749 section 2.3.1: https://tools.ietf.org/html/rfc6749#section-2.3.1 .. _RFC 6749 section 5.2: https://tools.ietf.org/html/rfc6749#section-5.2 N) exceptionsceZdZdZdZdS)ClientAuthTypeN)__name__ __module__ __qualname__basic request_bodyGC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\google/oauth2/utils.pyrr5s ELLLrrceZdZdZddZdS)ClientAuthenticationzDefines the client authentication credentials for basic and request-body types based on https://tools.ietf.org/html/rfc6749#section-2.3.1. Nc0||_||_||_dS)aInstantiates a client authentication object containing the client ID and secret credentials for basic and response-body auth. Args: client_auth_type (google.oauth2.oauth_utils.ClientAuthType): The client authentication type. client_id (str): The client ID. client_secret (Optional[str]): The client secret. N)client_auth_type client_id client_secret)selfrrrs r__init__zClientAuthentication.__init__?s!!1"*rN)rr r __doc__rr rrrr:s2 + + + + + +rrc<eZdZdZdfd Z ddZddZdZxZS) OAuthClientAuthHandlerzUAbstract class for handling client authentication in OAuth-based operations. Ncdtt|||_dS)zInstantiates an OAuth client authentication handler. Args: client_authentication (Optional[google.oauth2.utils.ClientAuthentication]): The OAuth client authentication credentials if available. N)superrr_client_authentication)rclient_authentication __class__s rrzOAuthClientAuthHandler.__init__Ss0 $d++44666&;###rcd||||||dSdS)aApplies client authentication on the OAuth request's headers or POST body. Args: headers (Mapping[str, str]): The HTTP request header. request_body (Optional[Mapping[str, str]]): The HTTP request body dictionary. For requests that do not support request body, this is None and will be ignored. bearer_token (Optional[str]): The optional bearer token. N)_inject_authenticated_headers"_inject_authenticated_request_body)rheadersr bearer_tokens r#apply_client_authentication_optionsz:OAuthClientAuthHandler.apply_client_authentication_options]sB **7LAAA    3 3L A A A A A rc"| d|z|d<dS|jy|jjtjurc|jj}|jjpd}t j|d| }d|z|d<dSdSdS)Nz Bearer %s Authorization:zBasic %s) rrrr rrbase64 b64encodeencodedecode)rr$r%usernamepassword credentialss rr"z4OAuthClientAuthHandler._inject_authenticated_headersps  #'2\'AGO $ $ $  ' 3+<@TTT2rLs8 """""" TY +++++6+++(?????s{????D>>>>>r