![]() ![]() Up to this point I’ve just copied code from someone else in openhab. GetAuth.apply(BASE_URL+TOKEN, Skydrop_, true, readResponse) Use the refresh token to get a new auth and refresh token GetAuth.apply(BASE_URL+TOKEN, receivedCommand.toString, false, readResponse) Use the AuthCode to get the auth and refresh tokens ![]() Skydrop_Expires.postUpdate(now.plusSeconds(Integer::parseInt(transform("JSONPATH", "$.expires_in", response))).toString) Skydrop_RefreshToken.postUpdate(transform("JSONPATH", "$.refresh_token", response)) Skydrop_AccessToken.postUpdate(transform("JSONPATH", "$.access_token", response)) LogInfo("skydrop", "Populating auth token Items") LogError("skydrop", "Failed to " + if(refresh) "refresh" else "obtain" + "auth token") Val response = readResp.apply(connection) LogInfo("skydrop", "Attempting to " + if(refresh) "refresh " else "acquire " + "auth tokens")Ĭ(request.getBytes("UTF-8")) Val HttpsURLConnection connection = tokenURL.openConnection() as HttpsURLConnectionĬtRequestProperty('content-type', 'application/x-www-form-urlencoded')ĬtRequestProperty('cache-control', 'no-cache') If(xhr.readyState = XMLHttpRequest.DONE & xhr.status = 200) ', 'authorization_code') ![]() Xhr.setRequestHeader("Accept", "application/json") Xhr.setRequestHeader("Content-Type", "text/plain") split our query string into its component partsĭocument.write("Preparing to update " + item + " Item.") stuff after # is not part of query string, so get rid of it Var queryString = url ? url.split('?') : (1) get query string from url (optional) or window This is a cloud - to - cloud authentication between (openhab in my case) and skydrop. This will be used for the OAUTH2 authentication. The first step as I said before is to get your API access - then you can get your API key and consumer secret. I’ll try to put together the “important” parts that you’ll need to adapt to your setup. ![]()
0 Comments
Leave a Reply. |