Authentication

About this task

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

Procedure

  1. Use the POST method to send the initial login request to the RESTCONF API server.
    Sample client request
    curl -k -d '{"username":"rwa","password":"rwa"}' 
    -H "Content-Type: application/json" 
    -X POST http://<Device_IP_Address>:8080/auth/token
  2. The RESTCONF server responds as follows:
    Sample server response
    {"token": "IjcyNzc2MS03Mjc3NjEtNmM2ZjYzNjE2Yy0zMTMwMmUzMjJlMzMzOTJlMzUzOCI.
    YtUL8Q.cBUfBcF5FumXQTEn1Dp0Ak0VHnY"}
    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'