'Get the apikey. Username and password are required
if auth is enabled. Makes and saves the apikey if it does not exist.
Required parameters:
None
Optional parameters:
username (str):     Your PlexPy username
password (str):     Your PlexPy password
Returns:
string:             "apikey"'

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

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