Login
In order to call the private methods, we need to obtain the user token to
pass in the apikey
HTTP header.
The login.cgi RPC is used to create a new user session.
It returns a JSON:
Where the value of the token
attribute is used as the value of the apikey
HTTP
header in subsequent calls to methods requiring authentication.
Example
Shell
curl \
--output - \
--request POST \
--header "content-type: application/json" \
--data '{"username":"admin","password":"admin"}' \
https://ripex2a.racom.eu/cgi-bin/login.cgi
Python
import json
import requests
import sys
password = "admin"
username = "admin"
language = "en"
target = "https://ripex2a.racom.eu/cgi-bin/"
res = requests.post(
f"{target}/login.cgi",
data=json.dumps({
'password': password,
'username': username,
'language_code': language}),
headers={ 'Content-Type': 'application/json' })
if res.status_code != 200:
print('Error: HTTP status code:', res.status_code)
sys.exit(42) #error
print(json.dumps(res.json(), indent=2))