I am using this command , per docs:hi,
you get a new ticket again for 2 hours if you reauthenticate
curl -k -d "username=root@pam&password=yourpassword" https://10.0.0.1:8006/api2/json/access/ticket
- platform: rest
resource: https://x.x.x.x:8006/api2/json/nodes
name: API TEST
verify_ssl: false
headers:
Cookie: 'PVEAuthCookie=PVE:root@pam:5E1BAB79::Cxmr3rm3SRDw....'
content-Type: application/json
method: GET
you don't need to use curl. you can use anything else to make the initial request for authentication, save the ticket, and use it afterwards. (most scripting languages will do the job. you can even do it in bash by saving the ticket after running curl)
1. yes1. i can use current token to query for API
2. after 2 hours i should create a script to do initial request for authentication (is this command for new ticket that goes here :
https://10.0.0.1:8006/api2/json/access/ticket ?)
3. with generated new ticket or cookie and should add that to my command which generates queries toward API
access/ticket
endpoint with your username & password and return the API ticket. also save the timestamp when you retrieve the ticket so you can renew it before 2 hours end. before each request you make call this method and check if the ticket is older than 1 hour for example. if yes reauth and return the new ticket.Thank you1. yes
2. for example you can write a method to authenticate to theaccess/ticket
endpoint with your username & password and return the API ticket. also save the timestamp when you retrieve the ticket so you can renew it before 2 hours end. before each request you make call this method and check if the ticket is older than 1 hour for example. if yes reauth and return the new ticket.
3. yes
Great news, looking forward to it!I've also started working on implementing proper 'API token' functionality that would allow stateless API usage:
https://pve.proxmox.com/pipermail/pve-devel/2019-November/040581.html
I'll pick that up again in the coming weeks.