I’m trying to create a phone app that can utilize the SmartThings API. I have one running based on manually generating an access token. Note: this is simpler version of the SmartThings app for controlling lights. I have 60 lights and need a simpler dashboard.
I’d like to implement a user log-in so that I don’t have to keep generating a new token every 24 hours. All the documentation points to implementing an OAuth workflow. I’ve done this manually based on directions similar to these:
Every example I’ve seen uses a url on httpbin as the redirect uri. This works when you manually perform the authorization step by pasting the SmartThings log-in link into a browser. This browser is then redirected and you can see the code included in the resulting uri.
However, I want to implement this in my Maui (.NET) code. Fortunately there is a class that automates the entire OAuth process: WebAuthenticator.
This is where the problem comes in. The phone apps I’ve seen and and Maui documentation all want a redirect uri that is a custom scheme, e.g. “myapp://”. This will redirect to your app instead of another website. SmartThings, however, will only authorize a redirect in the form of “https://”. This uri is specified when created the required OAuth-In App with the command, “smartthings.exe apps:create” from the cli tool.
So this is where I’m stuck.
- Can the OAuth-In App have a redirect uri that is for my phone app and not just https:?
- If no, how does my phone app specify a real https:// uri and retrieve the code returned during the OAuth workflow? I’ve seen references to phone apps being able to redirect http requests. If this were possible, I could create a fake uri for the OAuth-In App and when the phone app browser is redirected to it, it can intercept the call and direct it to my app instead. I’m not sure how to implement this, but I’m looking into it.
As a last resort I can spool up my own server similar to what is shown in the “Taming the OAuth 2.0 Beast” link earlier in this post, but that seems to defeat the whole intent of using a secure OAuth process.


