Getting HTTP/1.1 401 authentication failure when trying to authenticate proxmox through curl command

sharathji1990

New Member
Jan 26, 2022
3
0
1
35
Hi,
When I trying to authenticate proxmox through API or CURL command, I am getting Authentication Failure. The credentials are valid. I tried the same in GUI, but got
{"data":null}
Proxmox Version: 6.4

curl -v -k -d 'username=root@pam&password=xxxxxxxxx' https://172.11.12.1:8006/api2/json/access/ticket. The password contain a special character '@'
1643224616193.png

1643224248284.png

I am basically new to Proxmox API integration, any help in solving the issue is much appreciated.
P.S: Using valid credentials, thats how I am able to login to Proxmox GUI.
 
Hi,
The password contain a special character '@'
Some special characters like an ampersand &, for example, bite with the POST request parameter notation.

Can you try using curl's data-urlencode helper option to make it encode problematic characters safely.

Bash:
curl -v -k -d 'username=root@pam' --data-urlencode 'password=xxxxxxxxx'  https://172.11.12.1:8006/api2/json/access/ticket

https://curl.se/docs/manpage.html#--data-urlencode
 
Hi,

Some special characters like an ampersand &, for example, bite with the POST request parameter notation.

Can you try using curl's data-urlencode helper option to make it encode problematic characters safely.

Bash:
curl -v -k -d 'username=root@pam' --data-urlencode 'password=xxxxxxxxx'  https://172.11.12.1:8006/api2/json/access/ticket

https://curl.se/docs/manpage.html#--data-urlencode
Hi Thanks for your reply. I did try the -data-urlencode option which you provided, getting the same error. Do I need to install any additional package for support API calls in Proxmox. Since I am getting the same {"Data":Null} in GUI request as well post authentication using Linux PAM standard Authentication.
Currently I am stuck and unable to proceed. Any help is much appreciated.
 
it works for me using curl (with --data, --data-raw and encoded '@', -data-raw and normal '@', --data-urlencode with normal '@'). possibly there is some other character that requires encoding/special care? you can take a look at what the browser actually sends by looking at the network tab of your browser's developer tools - it should also offer you the option of copying the 'ticket' request in various formats, including as curl command line ;)
 
it works for me using curl (with --data, --data-raw and encoded '@', -data-raw and normal '@', --data-urlencode with normal '@'). possibly there is some other character that requires encoding/special care? you can take a look at what the browser actually sends by looking at the network tab of your browser's developer tools - it should also offer you the option of copying the 'ticket' request in various formats, including as curl command line ;)
Hi Thanks for the suggestion, I was able to get the URL in which the ticket is being sent. Its not the default json, it's extjs mode. The url is like this
1643907239012.png

I would have to check how to pass parameters for extjs mode, or would have to change the mode to json.