OAuth callbacks on localhost


#1

Hi there. Trying to write an app that will use a web service smartapp. Attempting to oauth to the app, all I get sent to the app to authorize my things, then get sent right back to the auth screen. I looked at IFTTT’s url and I am using something similar, but as soon as I auth, I go right back to the login screen, never hitting my app’s callback. Is there something limiting me from using a localhost callback (for development)? My url is like so:

https://graph.api.smartthings.com/oauth/authorize?response_type=code&client_id=a085ef72-22d7-479f-8b6f-645a9bd177dd&redirect_uri=http://localhost:8080/auth/smartthings/callback&scope=app


(Joshua Lyon (SharpTools.io Dashboard)) #2

Have you tried URL encoding the redirect_uri and using the loopback address 127.0.0.1 instead of localhost?

https://graph.api.smartthings.com/oauth/authorize?response_type=code&client_id=a085ef72-22d7-479f-8b6f-645a9bd177dd&scope=app&redirect_uri=http%3A%2F%2F127.0.0.1%3A8080%2Fauth%2Fsmartthings%2Fcallback

What kind of app are you writing?


#3

I had it encoded before but pulled that out as ifttt (which works) didn’t seem to. Same issues with 127.0.0.1.

https://graph.api.smartthings.com/oauth/authorize?response_type=code&client_id=a085ef72-22d7-479f-8b6f-645a9bd177dd&redirect_uri=http%3A%2F%2F127.0.0.1%3A8080%2Fauth%2Fsmartthings%2Fcallback&scope=app

Is there any sort of validation or something in my smartapp that I need to be aware of? It’s just a dummy/sample right now, I ma just trying to get the auth working. End goal is I am building a voice command thing and I just want to have my app be able to address individual devices (which it will do via a web service smart app). If I can get a web service to individual devices without having to make my own smart app for that I’d be happy to as well.


(Joshua Lyon (SharpTools.io Dashboard)) #4

The URL you provided with 127.0.0.1 as the redirect_uri worked fine for me. After I logged in and authorized a device, I was redirected to the localhost address provided with a URL parameter including the OAuth Code that needs to be exchanged for a token:

http://127.0.0.1:8080/auth/smartthings/callback?code=XXXXXX

As of right now, I understand the advice is to create a SmartApp with End Points if you want to interact with devices. It sounds the like the SmartThings team has heard the feedback though, so I hope they are looking into alternative solutions.

—side note—
Depending on what kind of voice control you are looking for, I developed an app for Android called SharpTools which provides Widgets and Tasker Integration. And @jodyalbritton is working on a web-based dashboard which has voice control features.

If you pair the SharpTools Tasker plugins with AutoVoice, you can easily setup voice commands like "Okay Google, turn the [device_name] on":


#5

Sorry for the long delay, I missed this response. Thanks much for taking the time. I got my server auth working (was some sort of bad cookie state with ST in one browser) so now am up and running with my basic backend for the custom voice/dashboard I’m building. I think without any intent to make it something generic and to solve for a single user – my wife – I can get it pretty solid :wink: