HTTP login with Curl

Below is an example of the login process using an authentication token with the HTTP over JSON API.

The HTTP over JSON API uses authentication tokens for access. The token is sent in a cookie called pxt-session-cookie in a response to a call to the auth.login endpoint. The auth.login endpoint accepts a POST request with a JSON body that has login and password properties in a top-level object.

$ API=https://manager.example.com/rhn/manager/api
$ curl -H "Content-Type: application/json" -d '{"login": "myusername", "password": "mypass"}' -i $API/auth/login

HTTP/1.1 200 200
...
Set-Cookie: pxt-session-cookie=<tokenhash>; ...
...
{"success":true,"messages":[]}

Once the login is successful, the retrieved cookie must be added to each subsequent request for authenticated access.