<gh_stars>1-10
from docusign_esign import ApiClient
from os import path

def get_jwt_token(private_key, scopes, auth_server, client_id, impersonated_user_id):
    """Get the jwt token"""
    api_client = ApiClient()
    api_client.set_base_path(auth_server)
    response = api_client.request_jwt_user_token(
        client_id=client_id,
        user_id=impersonated_user_id,
        oauth_host_name=auth_server,
        private_key_bytes=private_key,
        expires_in=4000,
        scopes=scopes
    )
    return response

def get_private_key(private_key_path):
        """
        Check that the private key present in the file and if it is, get it from the file.
        In the opposite way get it from config variable.
        """
        private_key_file = path.abspath(private_key_path)

        if path.isfile(private_key_file):
            with open(private_key_file) as private_key_file:
                private_key = private_key_file.read()
        else:
            private_key = private_key_path

        return private_key

def create_api_client(base_path, access_token):
    """Create api client and construct API headers"""
    api_client = ApiClient()
    api_client.host = base_path
    api_client.set_default_header(header_name="Authorization", header_value=f"Bearer {access_token}")

    return api_client
from docusign_esign import ApiClient
from os import path

def get_jwt_token(private_key, scopes, auth_server, client_id, impersonated_user_id):
    """Get the jwt token"""
    api_client = ApiClient()
    api_client.set_base_path(auth_server)
    response = api_client.request_jwt_user_token(
        client_id=client_id,
        user_id=impersonated_user_id,
        oauth_host_name=auth_server,
        private_key_bytes=private_key,
        expires_in=4000,
        scopes=scopes
    )
    return response

def get_private_key(private_key_path):
        """
        Check that the private key present in the file and if it is, get it from the file.
        In the opposite way get it from config variable.
        """
        private_key_file = path.abspath(private_key_path)

        if path.isfile(private_key_file):
            with open(private_key_file) as private_key_file:
                private_key = private_key_file.read()
        else:
            private_key = private_key_path

        return private_key

def create_api_client(base_path, access_token):
    """Create api client and construct API headers"""
    api_client = ApiClient()
    api_client.host = base_path
    api_client.set_default_header(header_name="Authorization", header_value=f"Bearer {access_token}")

    return api_client
Get the jwt token Check that the private key present in the file and if it is, get it from the file.         In the opposite way get it from config variable. Create api client and construct API headers