'Returns api key, requires username and password is active'

def _getApikey(self, username='', password=''):

    apikey = hashlib.sha224(str(random.getrandbits(256))).hexdigest()[0:32]
    if (plexpy.CONFIG.HTTP_USERNAME and plexpy.CONFIG.HTTP_PASSWORD):
        if ((username == plexpy.HTTP_USERNAME) and (password == plexpy.CONFIG.HTTP_PASSWORD)):
            if plexpy.CONFIG.API_KEY:
                self.data = plexpy.CONFIG.API_KEY
            else:
                self.data = apikey
                plexpy.CONFIG.API_KEY = apikey
                plexpy.CONFIG.write()
        else:
            self.msg = 'Authentication    is    enabled,    please    add    the    correct    username    and    password    to    the    parameters'
    elif plexpy.CONFIG.API_KEY:
        self.data = plexpy.CONFIG.API_KEY
    else:
        self.data = apikey
        plexpy.CONFIG.API_KEY = apikey
        plexpy.CONFIG.write()
    return self.data
