03-01-2023 01:22 AM
Hi Community,
I am trying REST communication with VSP 4450 on Fabric Engine 8.8. I have already open the web-server and RESTCONF interface. I am using basic auth (username:password) with the same credentials as the HTTP web server of the switch. My guess is I am not using the right authentication method to access the RESTCONF interface. I value every input on this matter, thank you for your feedback.
03-02-2023 01:02 AM
Hi Jave & Markus,
Thank you for your valuable input. I got it working using a mix of your input. My remarks hereby on how I got there:
- I can't authenticate via Basic Auth embedded in Postman but I pass the credentials via Body message in JSON.
- Credentials used are not the one from the web page but the one to access the switch via CLI
- Using Postman environment variable is a great idea to pass the bearer token around. I found out that:
* pm.environment.set("vossBearer", data.message.token) -> data.message.token is not a correct value to parse the JSON message. Maybe has the path changed from earlier VOSS versions?
* pm.environment.set("vossBearer", data.token); -> data.token is retrieving the token and setting the "vossBearer" key adequately.
* You have to be careful using multiple Postman environment as only one can be active at the same time.
03-01-2023 09:35 AM
Yes, indeed you have run first a login request and catch the access token to be entitled to run the RESTconf calls. For postman is a clever way to use environment variables and map the token to predefined variable used by other request later on. This save time testing the API.
03-01-2023 09:36 AM
here the code I've used
03-01-2023 06:09 AM
Hi Isaas,
Personally, I retrieve an auth token with username/password in the body of a POST request, like this:
In cURL:
curl --location 'http://X.X.X.X:8080/auth/token/' \
--header 'Content-Type: application/json' \
--data-raw '{"username":"<username>","password":"<password>"}'
With the token, you can then do a GET request with "X-Auth-Token" key into the header:
In cURL (example with LLDP neighbors):
curl --location 'http://X.X.X.X:8080/rest/restconf/data/openconfig-lldp:lldp/interfaces' \
--header 'X-Auth-Token:<token>'
Regards,
Jave