OAuth 2.0 Token exchange not completing

Hello, I’m trying to create an integration where smartthings connects to an azure function I have deployed, and retrieves devices from the database of another app I’m developing. I have done the same for google home and alexa successfully already.

I have created a cloud connector schema for this, and set up an azure ad b2c for the authentication flow. I added the c2c urls to the allowed redirect urls, and on the cloud to cloud project added the Ids, secrets, urls and scope necessary for it to work.

I deployed to test the project, and when I click on it on my smartthings app, it redirects to the login/authorization successfully, I login into my account and it then redirects me to another page with the following URL:

https://c2c-eu.smartthings.com/oauth/callback?state=[...]&code=[...]

So it is successfully retrieving the code that needs to be exchanged for a token, but for some reason I’m only getting a page on my phone that says:

Pretty print
{}

Am I missing something here?

Hi, @Henrique_Gaspar. Welcome to the SmartThings Community!
The Schema integration is used to add devices to the SmartThings platform that are accessible only through the Cloud, but I’m not sure if that’s what you’re trying to achieve, can you confirm, please?
Or, do you want to get an OAuth token to be able to control existing devices from a user? That is a different integration type.

Hello @nayelyz thank you for the quick response and for the welcome!

Yes that’s what I’m trying to achieve. Similar to alexa smart home skill and google home.

For more context, I have a smart home application where I can add smart home devices, these devices are stored in a database. What I want to do is allow for smartthings to interact with them.

To do that from what I understood I need to create a cloud connector, that uses an azure function url I created as a webhook to receive the, for example, discovery calls and retrieve/map the devices from my other application so that I can see the devices on the smartthings app in the smartthings format.

I should also say that I have created a smartapp to test, because the documentation gives two different solutions.

Bring Your Cloud Connected Devices to SmartThings | Developer Documentation | SmartThings

And using the same webhook, I was able to get the smartapp to call my azure function. But I would preffer to leave the handling of OAuth to smartthings instead of me having to code it. That’s why I think the problem is somewhere in the token exchange step

Hi @Henrique_Gaspar
Could you please provide the timestamp of the last test? If you don’t remember, please run the test again. Also, please share the Viper ID with us. You can find it in the Developer Workspace, as well as access to your account.

  1. Confirm the email account registered in the forum is the same one you use for SmartThings. If not, please share it with me over DM
  2. Enable support access to your account:
  3. Go to the SmartThings Web (my.smartthings.com )
  4. Log in to your Samsung Account
  5. Select Menu (⋮) and choose Settings
  6. Toggle on Account Data Access
  7. Select the time period and confirm - In this step, please select “Until turned off”, once the team finishes, we’ll let you know so you can disable it again.

I ran a test just now, got the same “Pretty print {}” page on https://c2c-eu.smartthings.com/oauth/callbacl?state=[...]&code=[...]

The Viper ID is: viper_e78924d0-e3e7-11ef-b233-85f100ddd700

And I allowed access in my account

Hi @Henrique_Gaspar

The team has reviewed your issue and is asking you to check if your SmartThings app is updated to the latest version from the App Store. Could you please confirm?

Yes the app has the latest version.

Isn’t there a way for me to see if the discovery request is being sent? Like cloud schema logs somewhere or something?

Also is there any known issues with Smartthings and Azure AD B2C for OAuth 2?

Could you share with us a screenshot of the “About SmartThings” section showing the app version, please?

Thanks for the information @Henrique_Gaspar

Could you please send us a screen recording showing the issue?
Also to analyze the problem, it is important to get app logs. You could help us to reproduce the error and, once you find it, send us the logs.

  1. Go to Menu > Gear Icon > About SmartThings
  2. Tap the SmartThings logo 10 times.
  3. This will open the developer’s space > tap ‘report a problem’
  4. This will send you to the report page. Select a frequency and write a short description of the issue.
  5. Click on “Report” and a log file will be generated for you to send over email, please do to build@smartthings.com

The engineering team mentioned that it is important to validate the following:

  1. SmartThings app configuration – Ensure that the SmartThings app is set up to handle deep links.
  2. Deep link permissions – Verify if your operating system (Android/iOS) allows the app to intercept deep links correctly.

Here is a video of what is happening:
Video of situation

At first, you see me activating a smartapp I created with my azure function as a webhook. When it gives me the error “There was a problem connecting…” I receive a CONFIGURATION call on my Webhook, so I know the webhook is working and can receive http requests.

Then I try to activate my cloud schema, by going to the devices. And as you can see by the video, after I complete the authentication, it gives me an error, but my Webhook doesn’t receive anything, I believe this is where I should receive a “Discovery” request on my webhook.

And after that, when I try to connect again, I always get the “Pretty print” page on https://c2c-eu.smartthings.com/oauth/callbacl?state=[…]&code=[…]

Hi @Henrique_Gaspar

Thanks for the information.We noticed that the logs were not sent, and the engineering team has requested them to analyze the issue. It is important to replicate the error again to provide updated logs with the full flow.

Additionally, could you clarify the purpose of your SmartApp?