Getting "Please select at least one device to authorize" when I try to authenticate


(Colin Goldberg) #1

Hi there,

As a newbie to SmartThings, I am having difficulty getting past this error message

when I try to authenticate a SmartApp.

To keep things simple (after getting nowhere with my own app), I browsed the available SamrtApps and pasted “Text Me When There’s Motion” into mine, tested it (it worked beautifully), and then started the auth process by sending the initial request to get a code value.

ie.
https://graph.api.smartthings.com/oauth/authorize?response_type=code&client_id=[client id as supplied in app settings]&scope=app&redirect_uri=https%3A%2F%2Fgraph.api.smartthings.com%2Foauth%2Fcallback

The Authorize/Deny page appeared - so far so good.

As stated above, the error message appears.

The “Text Me When There’s Motion” app - unmodified by me - has the following preferences:

preferences {
section(“When there’s movement…”){
input “motion1”, “capability.motionSensor”, title: “Where?”
}
section(“Text me at…”){
input “phone1”, “phone”, title: “Phone number?”
}
}

In my understanding, this is where any information about devices is found.

So what am I missing? I am sure it is something basic.

Colin G


Getting “Please select at least one device to authorize” when I try to authenticate
#2

Do you have any devices connected to your location? It should look like this if you do:


(Colin Goldberg) #3

No, I have no real devices - yet.

I made an assumption that I needed to, and could set up authentication - ie. get an oauth token - so that I could test inbound http get/post requests from my outside service to the smartapp.

How else would I be able to develop/test the smartapp - before any real devices are attached? All I want to do at this stage is to see that I can successfully receive http requests in a smartapp.

I have set up some skeletal code as follows to handle requests.

mappings {
path("/vents") {
action: [
GET: “listVents”
]
}
path("/vents/:id") {
action: [
GET: “showVentStatus”,
PUT: “updateVentStatus”
]
}
}

def listVents() {
log.debug “listVents: start”

}

def showVentStatus() {
log.debug “showVentStatus: start=” + request
def command = request.JSON?.command
if (command) {
log.debug “showVentStatus: command=” + command
}
}

Please help me understand how I can test this before I get anywhere near real devices.

Thanks

Colin G


#4

Create some virtual devices!

https://graph.api.smartthings.com/device/list


(Colin Goldberg) #5

I did not see anything about creating a ‘virtual device’ on that page. But I did create an entry ‘Motion Sensor 1’ with Network ID 1 (?) and ‘motion sensor capability’.

I tried the authentication process again - this time I see the checkbox for the Motion Sensor. But I got the same message.

Just in case the device name needed to match the name in the smartapp, I updated the device so that this was the case. But I still got the same error message.


#6

That’s exactly how you create a virtual device.

That error shouldn’t be popping up though so I’m a bit confused. Log out/log in maybe? @urman?


(Colin Goldberg) #7

One thing I see - the device is listed as INACTIVE.

But I also tried the following - always getting the same error message.

I ‘Set Location’ for the smartapp. I noticed that there were now two devices - a virtual device (as per the code) and the physical device I added.

So it does not look like ‘physical’ device entry is the right thing to do.

I ‘Set Location’ and selected ‘Motion Sensor 1’ (instead of ‘motion1’) and updated. Still the same error message.


(Andrew Urman) #8

Do you have phone number as a required field? Can you post your code?


(Colin Goldberg) #9

Hi,

A bit of background is appropriate here.

  • I was originally trying to run the authentication for a test SmartApp - and I got this (same) error
  • I did not know if I had mis-typed or omitted anything (eg. in ‘preferences’)
  • To eliminate any possibility of my coding having an effect, I thought that I should then try authentication on a ‘working’ app that I selected by browsing the available apps. I selected ‘Text Me When There’s Motion’ (app built by SmartThings) and made sure not to modify anything.
    ie.
    I clicked ‘New SmartApp’, named it ‘Test Auth’, selected ‘Text Me When There’s Motion’ and clicked Enable OAuth, Create. No modifications. This app does not have any mappings for inbound GET/POST etc.

In ‘Text Me When There’s Motion’:
The phone number is a required field - as evidenced when I run a simulation.

I did - as suggested - add a device, but then this shows up as a Physical Device - plus the Virtual Device - I am not sure what to make of this.

The error appears as discussed above.

My original ‘test’ app - which also got this error when I tried to authenticate - is as follows:

////Start

definition(
    name: "Motion Detection",
    namespace: "",
    author: "Colin Goldberg",
    description: "Motion Detection",
    category: "My Apps",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
    oauth: [displayName: "KH MD", displayLink: ""])


preferences {
	section("When the door opens/closes...") {
		input "contact1", "capability.contactSensor", title: "Where?"
	}
	section("Allow External Service to Control These Things...") {
		input "switches", "capability.switch", title: "Which Switches?", multiple: true, required: false
		input "motions", "capability.motionSensor", title: "Which Motion Sensors?", multiple: true, required: true
		input "locks", "capability.lock", title: "Which Locks?", multiple: true, required: false
  }
}

def installed() {
	log.debug "Installed with settings: ${settings}"

	initialize()
}

def updated() {
	log.debug "Updated with settings: ${settings}"

	unsubscribe()
	initialize()
}

def initialize() {
	// TODO: subscribe to attributes, devices, locations, etc.
    subscribe(contact1, "contact", contactHandler)
}

def contactHandler(evt) {
	log.debug "$evt.value"
}

mappings {
  path("/vents") {
    action: [
      GET: "listVents"
    ]
  }
  path("/vents/:id") {
    action: [
      GET: "showVentStatus",
      PUT: "updateVentStatus"
    ]
  }
}

def listVents() {
	log.debug "listVents: start"
    
}

def showVentStatus() {
	log.debug "showVentStatus: start=" + request
	def command = request.JSON?.command
	if (command) {
		log.debug "showVentStatus: command=" + command
	}
}

def updateVent() {
	log.debug "updateVent: start"
    
}

///////End


(Colin Goldberg) #10

Hi,

Any progress on this? This seems like something basic - I am hoping to get past this point soon.

With the information I have given above, you should be able to easily try this for yourself. What did you find?

Thanks

Colin G


(Colin Goldberg) #11

Please let me know when you are able to focus on this - it’s probably a very simple thing.

Colin G


(Andrew Urman) #12

@colin can you submit a support request? I’d like to take a look into your account and need permission in a support ticket. Just mention me anywhere in the ticket and it will find its way to me.


(Colin Goldberg) #13

I sent an email reply this morning - but just in case it did not get to you:

‘A ticket was already opened:
[SmartThings Support] Support request #67448: Need help with authenticating a user for a smartapp’

Thanks

Colin G


#14

Hi Colin,
Did you get anywhere? I am having the same problem.

Thanks


(Colin Goldberg) #15

No,

I’m still waiting for support to get back to me.

Colin G


#16

I solved my problem- it turns out that my app wasn’t published. I published it and it worked.


(Colin Goldberg) #17

So now, after having sent a number of emails to support and getting no response, I am wondering what’s going on. This is very disappointing! Is there no support available to me?

Colin G


(Jai Vasanth) #18

I am doing a very similar thing and trying to setup a web endpoint using oauth. I am following the instructions from smartthings developer guide (http://docs.smartthings.com/en/latest/smartapp-web-services-developers-guide/implementation.html)
However I am facing the exact same issue. I do have real devices and they are all active and work fine otherwise.
Any support here would be appreciated

Thanks
Jai


(Jai Vasanth) #19

Looking at the javascript console from my browser, I notice that the Authorize button makes a PUT request to https://graph.api.smartthings.com/api/smartapps/installations/$my_installation_id$ and this PUT gets a 400 status code back. This results in the “Please select at least one device to authorize” dialog box.

I was able to do a HTTP GET on my installation successfully.
Jai


(Jim) #20

Add me as a +1 on this. My real goal: I have a bbq Pit monitor I built with raspberry pi, and I’ve been having my smartthings app poll it by punching a hole in my firewall. I would prefer to have the node code on the pit monitor call directly to SmartThings with the rest API.

When I try to authorize to get a token, I get told to select a device; even though I don’t need a device, I just need access to the rest endpoint mappings. Adding a vestigial device to the code (random motion sensor in the house), did not solve the problem.

Ideas?