<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def construct(self, request, service=None, http_args=None, **kwargs):
 """ Construct a dictionary to be added to the HTTP request headers :param request: The request :param service: A :py:class:`oidcservice.service.Service` instance :param http_args: HTTP arguments :return: dictionary of HTTP arguments """


        if http_args is None:
            http_args = {}

        if "headers" not in http_args:
            http_args["headers"] = {}

        # get the username (client_id) and the password (client_secret)
        try:
            passwd = kwargs["password"]
        except KeyError:
            try:
                passwd = request["client_secret"]
            except KeyError:
                passwd = service.service_context.client_secret

        try:
            user = kwargs["user"]
        except KeyError:
            user = service.service_context.client_id

        # The credential is username and password concatenated with a ':'
        # in between and then base 64 encoded becomes the authentication
        # token.
        credentials = "{}:{}".format(quote_plus(user), quote_plus(passwd))
        authz = base64.urlsafe_b64encode(credentials.encode("utf-8")).decode(
            "utf-8")
        http_args["headers"]["Authorization"] = "Basic {}".format(authz)

        # If client_secret was part of the request message instance remove it
        try:
            del request["client_secret"]
        except (KeyError, TypeError):
            pass

        # If we're doing an access token request with an authorization code
        # then we should add client_id to the request if it's not already
        # there
        if isinstance(request, AccessTokenRequest) and request[
                'grant_type'] == 'authorization_code':
            if 'client_id' not in request:
                try:
                    request['client_id'] = service.service_context.client_id
                except AttributeError:
                    pass
        else:
            # remove client_id if not required by the request definition
            try:
                _req = request.c_param["client_id"][VREQUIRED]
            except (KeyError, AttributeError):
                _req = False

            # if it's not required remove it
            if not _req:
                try:
                    del request["client_id"]
                except KeyError:
                    pass

        return http_args