(
    request, token_uri, body, access_token=None, use_json=False
)
return response.status == http_client.OK, response_data
Makes a request to the OAuth 2.0 authorization server's token endpoint.
    This function doesn't throw on response errors.

    Args:
        request (google.auth.transport.Request): A callable used to make
            HTTP requests.
        token_uri (str): The OAuth 2.0 authorizations server's token endpoint
            URI.
        body (Mapping[str, str]): The parameters to send in the request body.
        access_token (Optional(str)): The access token needed to make the request.
        use_json (Optional(bool)): Use urlencoded format or json format for the
            content type. The default value is False.

    Returns:
        Tuple(bool, Mapping[str, str]): A boolean indicating if the request is
            successful, and a mapping for the JSON-decoded response data.
Makes a request to the OAuth 2.0 authorization server's token endpoint.
    This function doesn't throw on response errors.
Makes a request to the OAuth 2 . 0 authorization server s token endpoint . This function doesn t throw on response errors .
def _token_endpoint_request_no_throw(
    request, token_uri, body, access_token=None, use_json=False
):
    """Makes a request to the OAuth 2.0 authorization server's token endpoint.
    This function doesn't throw on response errors.

    Args:
        request (google.auth.transport.Request): A callable used to make
            HTTP requests.
        token_uri (str): The OAuth 2.0 authorizations server's token endpoint
            URI.
        body (Mapping[str, str]): The parameters to send in the request body.
        access_token (Optional(str)): The access token needed to make the request.
        use_json (Optional(bool)): Use urlencoded format or json format for the
            content type. The default value is False.

    Returns:
        Tuple(bool, Mapping[str, str]): A boolean indicating if the request is
            successful, and a mapping for the JSON-decoded response data.
    """
    if use_json:
        headers = {"Content-Type": _JSON_CONTENT_TYPE}
        body = json.dumps(body).encode("utf-8")
    else:
        headers = {"Content-Type": _URLENCODED_CONTENT_TYPE}
        body = urllib.parse.urlencode(body).encode("utf-8")

    if access_token:
        headers["Authorization"] = "Bearer {}".format(access_token)

    retry = 0
    # retry to fetch token for maximum of two times if any internal failure
    # occurs.
    while True:
        response = request(method="POST", url=token_uri, headers=headers, body=body)
        response_body = (
            response.data.decode("utf-8")
            if hasattr(response.data, "decode")
            else response.data
        )
        response_data = json.loads(response_body)

        if response.status == http_client.OK:
            break
        else:
            error_desc = response_data.get("error_description") or ""
            error_code = response_data.get("error") or ""
            if (
                any(e == "internal_failure" for e in (error_code, error_desc))
                and retry < 1
            ):
                retry += 1
                continue
            return response.status == http_client.OK, response_data

    return response.status == http_client.OK, response_data
def _token_endpoint_request_no_throw ( request , token_uri , body , access_token = None , use_json = False ) : if use_json : headers = { "Content-Type" : _JSON_CONTENT_TYPE } body = json . dumps ( body ) . encode ( "utf-8" ) else : headers = { "Content-Type" : _URLENCODED_CONTENT_TYPE } body = urllib . parse . urlencode ( body ) . encode ( "utf-8" ) if access_token : headers [ "Authorization" ] = "Bearer {}" . format ( access_token ) retry = 0 # retry to fetch token for maximum of two times if any internal failure # occurs. while True : response = request ( method = "POST" , url = token_uri , headers = headers , body = body ) response_body = ( response . data . decode ( "utf-8" ) if hasattr ( response . data , "decode" ) else response . data ) response_data = json . loads ( response_body ) if response . status == http_client . OK : break else : error_desc = response_data . get ( "error_description" ) or "" error_code = response_data . get ( "error" ) or "" if ( any ( e == "internal_failure" for e in ( error_code , error_desc ) ) and retry < 1 ) : retry += 1 continue return response . status == http_client . OK , response_data return response . status == http_client . OK , response_data