REST Data Interface (2020.0 LTS)
Hello,
Based on the manual (I attached the screenshot) I could pass auth token and get the code. However, I couldn't pass authentication of the access token.
Could you tell me the way to pass through?
myenv: PLCnext 2152, FW: 2020.0
Step1.
https://192.168.1.10/_pxc_api/v1.2/auth/auth-token
{"scope":"variables"}
=>I got the code : 5f6f6516617a6ad7
Step 2:
https://192.168.10.1/_pxc_api/v1.2/auth/access-token
{"code":"5f6f6516617a6ad7","grant_type":"authorization_code","username":"admin","password":"*******"}
=>Could not get any response.(because of time out)
I think the written manual is wrong. Please check the red circle of the attached screenshot.
Best regards,
Atsushi
Comments
UPDATE:
The typos in the documentation have now been fixed (thanks Gundula!).
=====================
Hello,
Thanks for the tips about the documentation - I will ask for that to be updated.
The JSON looks OK to me.
One problem might be the IP address in the second command - it is different to the IP address in the first command.
~ Martin.
Hi Atsushi,
I've made some weeks ago some tests with a small Python script and just tested them again with FW 2020.3.
It should work as follows:
Post:
https://192.168.178.150/_pxc_api/v1.2/auth/auth-token
{"scope": "variables"}
--> {"code":"a3bc88f6522ef0c0","expires_in":600}
Post:
https://192.168.178.150/_pxc_api/v1.2/auth/access-token
{"code": "a3bc88f6522ef0c0", "grant_type": "authorization_code", "username": "admin", "password": "12345678"}
--> {"state":"a3bc88f6522ef0c0","token_type":"Bearer","access_token":"4435fc3632d2116e","roles":[]}
Keep the HMI option (default) "Enforcement of User Levels" activated, otherwise you'll get a misleading result, that your password is wrong.
Which might be correct, but the authentication is disabled anyway ?.
My Python script is not ready to publish yet, but if you like I can give it to you by mail or just my postman library...
Frank
Hello Martin-san, Frank-san,
Thank you for the support. Now I passed the 2nd step and got the values.
Please close the issue.
Best regards,
Atsushi