Making REST requests to a SmartApp

Hi folks,

Context : I want to relay whether a room is occupied or not based on the motion sensor events.

So, this has two parts :

  1. Implementing the SmartApp that maintains the state (based on motion sensor events) and exposes the APIs that provide this state. I believe I have completed this part here.
  2. Make the REST API calls to this SmartApp to get the occupancy data.

I’m completely lost on Step-2 now !! I’m following this guide to make the REST request to the SmartApp. I’ve written the following python code so far :

import requests

payload = {'response_type': 'code',
           'client_id': '2e5a6ffb-6bfa-4c47-bde4-7398bfb76196',
           'scope': 'app',
           'redirect_uri': 'http://getHuddleRoomsStatus.com'}
r = requests.get('https://graph.api.smartthings.com/oauth/authorize', params=payload)

print r.content

But I don’t see any “Authorization Code” present in the response (which is apparently needed for the next step).

Could someone please help me out here on what I’m missing.

For reference this is a continuation of this post : Access Device Methods inside runIn()

Cheers,
Santhosh

If there is a better way to do Step-2 (via python) please please let me know about that too !

Why not use the new API instead of the one on the way to being deprecated?

Wait !!! Does this mean that I don’t even need the SmartApp running ? All I need to do is get the Access-Token and get the Devices’ Status via the API calls ?

:hushed::confused::scream:

Also, Thanks a lot @tgauchat !! You seem to come to my rescue everywhere :smiley:

As I understand, all we have to do is

  1. Obtain the OAuth token from https://account.smartthings.com/tokens
  2. Use the above to create GET/PUT/etc… (referring the ST-API Documentation)

And the above should give me the power to get status, turn on/off devices etc… ?

This sounds too good to be true !!! Please tell me that there’s no “But” here !

It’s definitely not going to be as easy or straightforward as it sounds; “but” it’s better than the old way.

:smile: :smile: I’ll take what I get. Will update if I am successful in my attempt.

Thanks for all the help @tgauchat !