Part 3: Authentication

Log in to use Nuix REST.

Now that you know your server is properly installed and configured, the first thing you will want to do is authenticate.

curl --location --request PUT 'http://localhost:8080/nuix-restful-service/svc/v1/authenticatedUsers/login' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
	"username":"username",
	"password":"password",
    "licenceShortName": "enterprise-workstation",
    "workers": 2
}'
{
    "username": "username", 
    "authToken": "9729a460-eda7-48dc-ba70-d12b3aae3c8d",
    "licenseShortName": "enterprise-workstation",
    "workersGranted": 2
}

Alternatively, you can use the following example script to log in.

import requests
import json

username="YOURUSERNAME"
password="YOURPASSWORD"
licenseType="enterprise-workstation"
numberOfWorkders=2

base_url = "{{host}}:8080/nuix-restful-service/svc"
headers =  {"Content-Type":"application/json"}

request_body = {
	"username":username,
	"password":password,
    "licenseShortName": licenseType,
    "workers": numberOfWorkers
}

def getToken():
    try:
        response = requests.put(base_url + "/v1/authenticatedUsers/login", data=json.dumps(request_body), headers=headers)
        token = response.json()['authToken']
        print("Successful retrived token: {}".format(response.json()['authToken']))
    except Exception as e:
        print(e)


getToken()
import requests
import json

username="YOURUSERNAME"
password="YOURPASSWORD"
licenseType="enterprise-workstation"
numberOfWorkders=2

base_url = "{{host}}:8080/nuix-restful-service/svc"
headers =  {"Content-Type":"application/json"}

request_body = {
	"username":username,
	"password":password,
    "licenseShortName": licenseType,
    "workers": numberOfWorkers
}

def getToken():
    try:
        response = requests.put(base_url + "/v1/authenticatedUsers/login", data=json.dumps(request_body), headers=headers)
        token = response.json()['authToken']
        print("Successful retrived token: {}".format(response.json()['authToken']))
    except Exception as e:
        print(e)


getToken()

You have now successfully authenticated to Nuix RESTful Service!