Can't implement OAuth for Cloud-To-Cloud

oauth

(Anton) #1

Hello!

I am developing a solution for a product and trying to implement C2C connection. I am in stuck with linking SmartThings with my backend via OAuth.

I get request

{
    "lifecycle": "CONFIGURATION",
    "executionId": "41d224ba-7de3-77ac-fe87-a56fa6f325c3",
    "locale": "en",
    "version": "0.1.0",
    "client": { 
        "os": "ios",
        "version": "1.6.17",
        "language": "uk" 
    },
    "configurationData": { 
        "installedAppId": "7393625f-64d5-42cb-a52f-7935a677c4bb", 
        "phase": "PAGE", 
        "pageId": "linkPage", 
        "previousPageId": "", 
        "config": {} 
    }, 
    "settings": {} 
}

And return response, that is rendered in SmartThings App:

{ 
    "configurationData": { 
        "page": { 
            "pageId": "linkPage", 
            "nextPageId": "", 
            "previousPageId": "", 
            "complete": true, 
            "name": "Account Linking", 
            "sections": [ { 
                "name": "Please, link SmartThings to your XXXXXX account", 
                "settings": [ { 
                    "id": "linkAccount", 
                    "name": "Link Account", 
                    "type": "OAUTH", 
                    "required": true, 
                    "urlTemplate": "https://xxxxxx.auth.us-east-2.amazoncognito.com/login?response_type=code&client_id=20kucf9dcg5ju9deqeppugqft1&state=7393625f-64d5-42cb-a52f-7935a677c4bb&redirect_uri=https%3A%2F%2Fapi.smartthings.com%2Foauth%2Fcallback" 
                } ] 
            } ] 
        } 
    } 
} 

Authentication passes successfully and returns code to callback like that:
https://api.smartthings.com/oauth/callback?code=9dfea1ca-54e8-47e8-ba90-24f20068ad2b&state=7393625f-64d5-42cb-a52f-7935a677c4bb

But the callback returns HTTP 401.

I’ve read this topic Cloud to Cloud OAuth (Rest API) and did not find a solution. No more helpful info I could found on the Web.

Has anybody implemented this with success?

The Support is awful - no response for several days… From my previous Support contacting experience - they can respond after several weeks…

Thank you!


(Jim Anderson) #2

@atlascoder are you using iOS or Android mobile client? Does it work on one but not the other, or broken in both?


(Anton) #3

Hello, Jim!

I used iOS app on iPhone and also I tested OAuth url directly on Mac through Chrome browser.

I case with the app I did get blank white screen after authentication, and when I tried via Chrome I got to pointed redirect successfully and the redacted page responded with HTTP 401.

Also, I know that to get successful OAuth on SmartThings side, in contrast with my case where I need to authenticate on my backend in order to access to devices data from my cloud, - on SmartThings side special request to ST is required. Maybe such request is required to use OAuth when linking to own cloud too?

Thanks for helping me!


(Jim Anderson) #4

We’ve recently discovered a bug on the iOS mobile app that sounds like what you are experiencing. Engineering is working on a fix.

If you have access to an Android phone, you could check to see if it works there, as there may be other issues that would result in a 401 and blank screen.

No, this doesn’t require any special access.

Stay tuned, I’ll update here when the iOS bug is fixed. My apologies for the inconvenience, I know this is frustrating.


(Anton) #5

Jim, just checked on Android and it works!
Thank you very much for the help!!
We will be waiting for news about fixes for iOS.