Communication by OAuth2 with an android application

I’m new to this forum. I am a trainee in a small company that asks me to have a java android app communicate with a product they are developing. It uses the smartthing system that I find great but I can not create a communication from the application.
I find examples of getting token and refreshToken but no way to communicate.
And I do not know on what exact address I have to make my requests.

Sorry about my approximate English.

Have you read: ?

1 Like

Yes I have read the part on the “SmartApps Web Services” but I can not understand how I can send and receive json via a json code (which will vary depending on the number of devices connected to the hubs)
and in this tuto is create an web apps no android apps, Which adds a bit of difficulty to me ^^

You’re with the most sophisticated smart home platforms that exists, so … don’t expect it to be “easy” :wink:.

  1. I suggest starting with a web-based app as a prototype for your project, as that is a good way to ensure you learn the concepts. Exchanging JSON requests via a REST-API in a “Web Services SmartApp” is the most basic step you need to learn and it is well documented.

  2. There are at least 100 Topics (probably much more) that discuss web services SmartApps and there is a ton of example code:

Such as:

####Basic Concept:
SmartThings does not offer an API directly to Devices; instead you use or write a SmartApp that lets the user authorize Devices to connect with and your SmartApp offers “REST-API” endpoints" to query or post via HTTPS.

thank you,
I realized that I was too new for this, and that it was not simple !!
But that’s nobody in society can help me and I was lost.

I will follow your advice and start with a web service.

PS: the link …/master/endpoint.groov don’t work, This link must be used i think.

1 Like


I’m back after a lot of work !!!
Working on the web application helped me a lot. After to add it to my Android application I have not badly battled and have helped myself of example.

I put online my project (part connection by OAuth2, retrieval and sending of data):

I met some weird things. That I made sure not to take care of it. But I would like to understand them.

When I request the EndPoint I receive a Json with 2 different codes:*****----2e0a47
The second corresponds to the link that I get on the simulator of my smartapp (is it walk)

After requesting to my application I Json it returns me contain unnecessary “n” that I am forced to remove with processing the json:

[n {n “name”: “Kitchen”,n “temp_act”: 19.1,n “temp_went”: 21.5,n “timed1”: 0,n “timed2”: 240n },n {n “name”: “BedRoom”,n “temp_act”: 15.1,n “temp_went”: 20.5,n “timed1”: 0,n “timed2”: 80n }n]n

I also have a small question about identifying CLIENT_ID and CLIENT_SECRET, when I would have published my Smartapp codes will change or remain the same?
(I think they have to change)

If it’s change, is there a way to get them right with the user’s Smartthings account Login? To avoid manipulation to the future user.