def gen_artifactory_auth_token()

in job-worker/npm_job_worker.py [0:0]


def gen_artifactory_auth_token(configuration):
    hostname = configuration['ArtifactoryHost']
    username = configuration['UserName']
    pwd = configuration['Password']
    # We want to get a token from Artifactory so we don't save the Username and Password in the .npmrc file: curl -uUSERNAME:PASSWORD -XPOST "http://ARTIFACTORY_HOST/artifactory/api/security/token" -d "username=config['UserName']" -d "scope=member-of-groups:*"
    data = {'username': username, 'scope': 'member-of-groups:*'}
    token_url = hostname + '/artifactory/api/security/token'
    get_token = requests.post(token_url, data=data, auth=(username, pwd))
    token = ast.literal_eval(get_token.text)['access_token']
    return(token, hostname, username)