I am working on a REST Endpoint trying to follow these instructions from @Ben
Everything works fine util step 3
Step 1: I redirect to get the code. ST login and device selection is displayed and I select the devices I want access to.
Step 2: I am returned json with the access_token
I get the access token from the json and forward to myself
Step 3: I reach my routine with the access_token populated and make the call to get the data. But I am always returned only
Not sure how to debug this at this point since ST is always returning empty results.
The call I make in step 3 is
where … is my access token. I write the token I get from step 2 and it matches what is in this request.
I don’t know php that well so I am guessing at Ben’s code.
I am writing my code in Spring Boot.
I notice Ben makes the calls differently for the access_token call which returns json and the call which returns the data.
The first uses curl
$page = “https://graph.api.smartthings.com/oauth/token?grant_type=authorization_code&client_id=".$client."&client_secret=".$secret."&redirect_uri=".$url."&code=".$code."&scope=app”;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $page );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_POST, 0 );
curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: application/json’));
$response = json_decode(curl_exec($ch),true);
The second uses file which I don’t really understand
$url = “https://graph.api.smartthings.com/api/smartapps/endpoints/$client?access_token=”.$_REQUEST[‘access_token’];
$json = implode(’’, file($url));
I think the difference between these may be my issue.
I am using the same technique for both steps and wondering if this is what I am doing wrong.
Why is the different technique used for the second step.
As a test I just forward in step 3 to the url
and I get the blank [ ] displayed in the browser.