API Authentication

  • 11 Replies
  • 14012 Views

0 Members and 3 Guests are viewing this topic.

*

Offline alex_noyes

  • Newbie
  • *
  • 4
  • 1
API Authentication
« on: June 18, 2018, 03:04:50 PM »
Looking at the Swagger page for the magic info premium server api's, I am unable to find some more documentation on how to setup authentication.
What do the headers looks like for the POST request? I just keep getting a 401 error... is there anything I need to configure on the server for API access or token generation?

Thanks,
Alex.

*

Offline Pepijn

  • SuperHero & MegaGuru
  • ******
  • 182
  • 88
Re: API Authentication
« Reply #1 on: June 20, 2018, 03:11:30 PM »
Dear Alex,

Hope this guide will help you:
http://displaysolutions.samsung.com/docs/display/MS1/Open+API

Kind regards,
Pepijn.

*

Offline alex_noyes

  • Newbie
  • *
  • 4
  • 1
Re: API Authentication
« Reply #2 on: June 20, 2018, 03:37:43 PM »
Thanks Pepijn,

That was the first API page I saw, it does not tell me what format the username and password need to be in. Am I sending them as Basic Auth or as parameters in the post?

Thanks,
Alex.

*

Offline chris.porter

  • Newbie
  • *
  • 1
  • 0
Re: API Authentication
« Reply #3 on: August 21, 2018, 04:22:33 PM »
did you find an answer to this?  I'm struggling with authentication as well

*

Offline alex_noyes

  • Newbie
  • *
  • 4
  • 1
Re: API Authentication
« Reply #4 on: August 21, 2018, 04:56:43 PM »
Hey Chris,
I am still no further forward with this.

Cheers,
Alex.

*

Offline vllanten

  • Newbie
  • *
  • 3
  • 2
Re: API Authentication
« Reply #5 on: January 02, 2019, 03:02:00 PM »
Effectively, there is no documentation on how to do the login, however it works as follows:

curl -X POST http://127.0.0.1:7001/MagicInfo/auth -H 'content-type: application/json' -d '{ "username" : "admin", "password" : "admin2016"}'

a POST request to the authentication path, sent json parameters, (username / password)

Regards!!

*

Offline Kmilo1488

  • Newbie
  • *
  • 1
  • 4
Re: API Authentication
« Reply #6 on: March 30, 2019, 03:45:19 PM »

Hi, I made this example, I hope I help you, https://github.com/Kmilo1488/magic_info

*

Offline baby.bear85

  • Newbie
  • *
  • 2
  • 0
Re: API Authentication
« Reply #7 on: April 18, 2019, 02:06:08 PM »
Hi all,

I'm quite new to MagicInfo API, as far as I know, the Open API have been "replaced" by Rest API, but there are so much details about the authentication step (http://displaysolutions.samsung.com/docs/display/MS1/Open+API) and I'm still stuck on this.

Is there any similiar GET to  " url: "http://192.168.10.74:7001/MagicInfo/openapi/auth?cmd=getAuthToken&id="+id+"&pw="+pw+""?

How can I pass my username and password, using the Rest API?

I only get this:

loadingTime: "500", mobileUrl: "/MagicInfo/...", mobileVersion: null, retryCount: "5", serverVersion: "MagicInfo S...", sizePerMonitoring: "50", sizePerPage: "20", urlPrefixV1: "/restapi/v1.0"}

*

Offline alex_noyes

  • Newbie
  • *
  • 4
  • 1
Re: API Authentication
« Reply #8 on: May 20, 2019, 03:02:10 PM »
Hi, I made this example, I hope I help you, https://github.com/Kmilo1488/magic_info

Thanks for this Kmilo. I was under the impression that the OpenAPI stuff has been depreciated and the RestAPI was now in use "/MagicInfo/swagger-ui.html#!/"

I will look into it further and report back soon  :)

Cheers,
Alex.

*

Offline jknowles

  • Newbie
  • *
  • 2
  • 1
Re: API Authentication
« Reply #9 on: November 24, 2022, 10:45:46 AM »
I know this is a rather old topic, but still seems to get views on it.
To access the api, first you need to send the api request to  ..../MagicInfo/restapi/v2.0/auth   with content-type:application/json in the header, and  {"username":"password"} in the body of the the request, using the POST method.
You'll then receive a json response with token, refreshToken, dateFormat ,timeFormat, and scheduleFirstDay.   Parse the response stream and use the value from token in all your subsequent api calls by adding it into the header for your next request under the key named "api_key" with the value being from the previous response "token".  It's kind of confusing that you are renaming what the variable is called between the auth response and subsequent requests .
I just ran the example through fiddler:

REQUEST

POST https://myserver/MagicInfo/restapi/v2.0/auth HTTP/1.1
User-Agent:Fiddler Everywhere
Content-Type:application/json
Host:ss.10net.net:7002
Content-Length:52

{"username":"jknowles","password":"signageisfun"}

Response:

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Access-Control-Allow-Origin: *
X-FRAME-OPTIONS: SAMEORIGIN
X-Content-Type-Options: nosniff
Content-Security-Policy: default-src 'self' 'unsafe-inline' 'unsafe-eval'  blob:; img-src 'self' data:;worker-src blob:;
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Access-Control-Allow-Methods: POST, GET, PUT, OPTIONS, DELETE
Access-Control-Max-Age: 3600
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, api_key
X-Frame-Options: SAMEORIGIN
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Thu, 24 Nov 2022 09:55:52 GMT

70e
{"token":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx","refreshToken":"yyyyyyyyyyyyyyyyy","dateFormat":"yyyy-MM-dd","timeFormat":"24hour","scheduleFirstDay":"0"}
0

I then use the token in my request for list of devices

Request:
GET https://myserver/MagicInfo/restapi/v2.0/rms/devices?pageSize=15&startIndex=1 HTTP/1.1
Content-Type: application/json
api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Host: myserver

Response:

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Access-Control-Allow-Origin: *
X-FRAME-OPTIONS: SAMEORIGIN
X-Content-Type-Options: nosniff
Content-Security-Policy: default-src 'self' 'unsafe-inline' 'unsafe-eval'  blob:; img-src 'self' data:;worker-src blob:;
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Access-Control-Allow-Methods: POST, GET, PUT, OPTIONS, DELETE
Access-Control-Max-Age: 3600
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, api_key
X-Frame-Options: SAMEORIGIN
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Thu, 24 Nov 2022 10:35:43 GMT

2000
{"apiVersion":"2.0","status":"Success","items":[{"deviceName":"WP-320-Middle","deviceId":"f0-70-4f-0f-2e-2c","deviceType":"SPLAYER","deviceTypeVersion":7.0,"power":true,"groupNam

  etc. etc


Hope this helps!!1