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

sharathji1990

New Member
Jan 26, 2022
3
0
1
32
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.
 

t.lamprecht

Proxmox Staff Member
Staff member
Jul 28, 2015
5,213
1,516
164
South Tyrol/Italy
shop.proxmox.com
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
 

sharathji1990

New Member
Jan 26, 2022
3
0
1
32
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.
 

fabian

Proxmox Staff Member
Staff member
Jan 7, 2016
7,483
1,395
164
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 ;)
 

sharathji1990

New Member
Jan 26, 2022
3
0
1
32
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.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!