Authentication

You must start a valid session by sending a basic authentication request to the RESTCONF server, before you can start making API calls. There are no limits on the number of requests per session.

  1. Use the POST method to send the intial login request to the RESTCONF API server.
    Sample client request
    curl -X POST http://<Device_IP_Address>/auth/token \
    -H 'Content-Type: application/json' \
    -d '{
        "username": "<YOUR_USERNAME_HERE>",
        "password": "<YOUR_PASSWORD_HERE>"
    }'
    
  2. The RESTCONF server responds as follows:
    Sample server response
    {
        "duration": 86400,
        "token": "eyJhbGciOiJIUzI1NiIsImV4cCI6MTU3MDE5MDk3OSwiaWF0IjoxNTcwMTA0NTc5fQ.
            eyJ1c2VybmFtZSI6ImFkbWluIiwiYWNjZXNzX2xldmVsIjoiYWRtaW4ifQ.
            I2uaCxQ8v5-ShAaZHwUbS76e9LZ22Who4icgLBwmVc8"
    }
    Note

    Note

    The token is valid for a day and can be used to send subsequent requests. Include the token in the request header for all subsequent API calls.
    Including the authorization token as a cookie in the request header
    curl -X GET http://<Device_IP_Address>/rest/restconf/data/openconfig_vlan:vlans/vlan=1/config \
    -H 'Content-Type: application/json' \
    -H 'Cookie: x-auth-token=eyJhbGciOiJIUzI1NiIsImV4cCI6MTU3MDE5MDk3OSwiaWF0IjoxNTcwMTA0NTc5fQ.eyJ1c2VybmFtZSI6ImFkbWluIiwiYWNjZXNzX2xldmVsIjoiYWRtaW4ifQ.
    I2uaCxQ8v5-ShAaZHwUbS76e9LZ22Who4icgLBwmVc8'