{"id":1724,"date":"2017-11-12T01:00:26","date_gmt":"2017-11-11T23:00:26","guid":{"rendered":"https:\/\/einstein.amsterdam\/?page_id=1724"},"modified":"2017-11-16T21:19:34","modified_gmt":"2017-11-16T19:19:34","slug":"sharkrf-openspot-remote","status":"publish","type":"page","link":"https:\/\/einstein.amsterdam\/?page_id=1724","title":{"rendered":"SharkRF openSPOT API"},"content":{"rendered":"<p>Due to the existence of an API on the openSPOT, we need todo some hacking \ud83d\ude09<\/p>\n<p>Link to the API description <a href=\"https:\/\/github.com\/sharkrf\/osp-http-api\" rel=\"noopener\" target=\"_blank\">here<\/a><\/p>\n<p>All queries except gettok.cgi, ip.cgi and checkauth.cgi must include a valid JWT (JSON Web Token). The JWT should be included in the HTTP header as Authorization: Bearer.<\/p>\n<p>First steps :<\/p>\n<p>1. You need to get a token from the openSPOT with http:\/\/openspot.local\/gettok.cgi<br \/>\n {<br \/>\n   &#8220;token&#8221;: &#8220;1f9a8b7c&#8221;<br \/>\n }<\/p>\n<p>2. You have to add your password to the token and sha256 this (shasum -a 256)<\/p>\n<p>sha256(&#8220;1f9a8b7cpassw0rd&#8221;)<\/p>\n<p>3. You have to POST this to http:\/\/openspot.local\/login.cgi in JSON<br \/>\n {<br \/>\n   &#8220;token&#8221;: &#8220;1f9a8b7c&#8221;,<br \/>\n   &#8220;digest&#8221;: &#8220;2c476e1191ac5d38f72d9b00aca1c1a64aebe991de8c2c4806e413016844e6be&#8221;<br \/>\n }<\/p>\n<p>4. The reply will contain a JWT (JSON Web Token) entry. The JWT stays valid for 3600 seconds after the last valid query.<br \/>\n {<br \/>\n   &#8220;hostname&#8221;: &#8220;openspot&#8221;,<br \/>\n   &#8220;jwt&#8221;: &#8220;eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJkMjljODQwZSJ9.r3Oom8qVEAd1ceMMWibrMNsgu0DPgz-IG13MAzB-o5s&#8221;<br \/>\n }<\/p>\n<p>Now we are logged in and can call all API interfaces with the acquired JWT.<\/p>\n<p>Let&#8217;s make a script for this, click <a href=\"https:\/\/einstein.amsterdam\/?page_id=1745\">here<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Due to the existence of an API on the openSPOT, we need todo some hacking \ud83d\ude09 Link to the API description here All queries except <a class=\"mh-excerpt-more\" href=\"https:\/\/einstein.amsterdam\/?page_id=1724\" title=\"SharkRF openSPOT API\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"_links":{"self":[{"href":"https:\/\/einstein.amsterdam\/index.php?rest_route=\/wp\/v2\/pages\/1724"}],"collection":[{"href":"https:\/\/einstein.amsterdam\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/einstein.amsterdam\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/einstein.amsterdam\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/einstein.amsterdam\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1724"}],"version-history":[{"count":21,"href":"https:\/\/einstein.amsterdam\/index.php?rest_route=\/wp\/v2\/pages\/1724\/revisions"}],"predecessor-version":[{"id":1753,"href":"https:\/\/einstein.amsterdam\/index.php?rest_route=\/wp\/v2\/pages\/1724\/revisions\/1753"}],"wp:attachment":[{"href":"https:\/\/einstein.amsterdam\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1724"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}