Authentication and Authorization

You must start a valid REST session by sending a basic authentication request to the NSight API server before you can start making API calls. The request should include a valid administrator user name and password. The NSight server can use authentication mechanisms such as local database, RADIUS, etc, but the actual authentication mechanism(s) depends on the configuration of the WiNG device.

Note

Note

NSight's REST API is protected by the same access restrictions which are provided via the WiNG command line or graphical user interface. For example, if a user role does not allow write access to a resource, then an attempt to configure/update this resource via REST will fail. For more information on NSight user roles, see the NSight User Guide on https://www.extremenetworks.com/support/documentation/.

Sample Login Request

curl -L -H 'User-Agent: Mozilla' -H 'Cookie:troute=t1;'
'http://<NSight_Host_IP_Address>/nsight-ui/api/v1/login?username=<username>&password=<password>'
<NSight_Host_IP_Address> The IP address of your NSight server
<username> Your NSight account user name
<password> Your NSight account password

Sample Login Response

 {
	"success":true,
	"user":"admin",
	"role":"superuser",
	"session_id":"yskju15kx0nYVZ41t9ytcfcUMW9dBl3K",
	"fw_version":"5.9.3.0-6907683X",    
	"serial_no":"7C47B72621E71E6E"
}
Note

Note

Save the session_id as a shell variable and forward it for authentication in subsequent API calls.

Forwarding session_id in subsequent API calls

cookie = yskju15kx0nYVZ41t9ytcfcUMW9dBl3K

curl -X GET --cookie auth_token=$cookie http://134.141.242.93/nsight-ui/api/v1/ap_stats
You can send a logout request to the NSight API server to close a session.
Note

Note

An idle REST session is terminated automatically by the WiNG device after the duration exceeds the idle-session-timeout value in the management policy. The default interval is 30 minutes.

Sample Logout Request

curl -X GET --cookie auth_token=$cookie http://134.141.242.93/nsight-ui/api/v1/logout 

Sample Logout Response

{   
	"data": {
		"status": "logged out"
	}
"success": true
}
Note

Note

After you log out or if the session expires, you need to log in and start a new session to continue making API calls. You will see an error message if your session is no longer active.

Sample Error Response if Session is not Active

{        
	"success": false,    
	"data":{     
		"error': "Logged out"    
		}
}