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

  1. Login to the NSX Advanced Load Balancer UI.

  2. Click the three dots in the dashboard.



  3. Click Generate Token.



    A pop-up screen appears as shown below:



  4. Enter the Lifetime for the token’s validity in hours.



    Note:
    1. To generate a single use token, enter 0.

    2. The maximum value that can be entered in this field is 87600 hours.

    3. In case another token is generated before the first one expires, the first token still remains valid.

  5. Click Generate. The token is generated and displayed as shown below:



  6. 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')