Trouble with REST API and Authentication

Hello, I’ve been using the REST sensor template successfully to access certain stats from my Nokia Fastmile (cellular based modem). The stats I have been retrieving do not require a login to access the data.
I’m looking to pull more data from the modem which will require a login and authorization to get access to those pages.

Looking at the debug code in Chrome when logging into the web interface, I see the following 3 commands and responses with each Login:

Request: http://192.168.1.1/login_web_app.cgi?nonce
Response: {“nonce”:“6p7UXbwofEFMrdCZd3rdo8zYzI6pvrtVRjUfgDpIo7U=”,
“randomKey”:“632”,
“iterations”:1,“pubkey”:“-----BEGIN PUBLIC KEY-----~ 200 byte key-----END PUBLIC KEY-----”}

Request: http://192.168.1.1/login_web_app.cgi?salt
Response: {“alati”:“”
}

Request: http://192.168.1.1/login_web_app.cgi
Response: {“result”:0,“sid”:“tcpTEMndllvSCHpF”,“token”:“bqtIMdhlcPZBpPfP”}

After that, pages can be accessed, and the Session ID is referenced in the header of all page requests.
I can use curl commands to successfully retrieve page information with an SID that was created through the web page authorization, but I cannot find a way to retrieve a unique SID when attempting to authorize using curl.

When I use the following command, it is successful and returns the same response as shown in the first web browser response.

curl -X POST http://192.168.1.1/login_web_app.cgi?nonce -H ‘Content-Type: application/json’ -d ‘{“userName”:“MyUserName”, “password":“MyPassword”}’

What I cannot figure out is how to retrieve the Session ID. I’ve tried different variations of using the Public Key, but everything returns a 401 error.

The web based login appears to use the one time and random keys as additional encoding. Would that encoding have to be replicated with each login, or can I use the public key in some way as authentication? I’ve gone in a bit over my head on this one unfortunately…