Hi All,
I'm looking to Log In to the Dashboard Developer REST HTTP API of a printer we have on site using Node Red to get the access token and ultimately be able to receive status information of the printer and forward it on to a PLC (Siemens)
Regarding the Log In to the API, the below instruction are given by the Printer supplier:
#######################################################################
Prerequisites
Make sure that you have the following prior to proceeding on with this section:
- Your AAAAAAAA.com username and password
- You have AAAAAAAA printer(s) connected to your AAAAAAAA.com account
- You have received the client ID and the client secret from AAAAAAAA
Login
Log in by sending an HTTP POST request to https://api.AAAAAAAA.com/developer/v1/o/token/ with
the following parameters in application/x-www-form-urlencoded content type:
● "grant_type": "password"
● "username": "your_AAAAAAAA_account_username"
● "password": "your_AAAAAAAA_account_password"
● "client_id": "your_client_id"
● "client_secret": "your_client_secret"
Example
The following is an example request of logging in using cURL command line tool. Please open
your Shell/Terminal and type the following:
curl --request POST \
--url https://api.AAAAAAAA.com/developer/v1/o/token/ \
--header 'content-type: application/x-www-form-urlencoded' \
--data
'grant_type=password&client_id=your_client_id&client_secret=yo
ur_client_secret&username=your_username&password=your_password
'
On Windows machines, you may need slightly different syntax like the following example:
rl -X POST https://api.AAAAAAAA.com/developer/v1/o/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d \
"grant_type=password&client_id=your_client_id&client_secret=yo
ur_client_secret&username=your_username&password=your_password
"
The API should return something like this:
{
"access_token": "your_access_token",
"token_type": "Bearer",
"expires_in": 86400,
"refresh_token": "your_refresh_token",
"scope": "developer-api"
}
###############################################################################
Iv created a very basic flow in NODERED to try and see if could connect and replicate the expected return:
and wrote function:
with HTTP Request Node:
Unfortunately it is not working for me and i don't have enough of an understanding of JSON or NODE RED, to know why. If any could give me some pointers, it would be much appreciated.
TIA