To access an NSX Advanced Load Balancer SaaS instance through the REST API, a registered user must have a valid token. Once that token has been created, the user can authenticate to the NSX Advanced Load Balancer Controller REST API using the token as the password.
Generate the Authorization Token
Login to the NSX Advanced Load Balancer UI.
Click the three dots in the dashboard.
Click Generate Token.
A pop-up screen appears as shown below:
Enter the Lifetime for the token’s validity in hours.
Note:To generate a single use token, enter 0.
The maximum value that can be entered in this field is 87600 hours.
In case another token is generated before the first one expires, the first token still remains valid.
Click Generate. The token is generated and displayed as shown below:
Copy the token.
Login to NSX Advanced Load Balancer SaaS REST API
As shown in the SDK example below, access the Controller API using the token as your password.
from avi.sdk.avi_api import ApiSession api = ApiSession.get_session("avikb.saas.avinetworks.com", "[email protected]", "499e4c833c183312f3eeab2c9f5e8bd47c48d440", tenant="kb") #----- retrieve virtualservices resp = api.get('virtualservice')