Hello SmartThings community,
Scenario: When my home door opens, The user should be notified on 3p ( android) client app.
Can my OAuth-In App (created using SmartThings cli) get notified of device events (for every user)? May be if i provide targer URI? Can it be done?
I saw the Subscription apis but they require InstalledApp id. When a user signs in and access_token is generated it is equivalent to a smartApp installation. So it must have an installedApp id. I was considering this but i dont get any information (installedApp info) on āList Installed Appsā API hit.
Can you confirm - āSubscription APIs can be used for OAuth-In Appā?
Hi @Krushnali_Tiwari ,
- What is 3p?
Could you clarify what you mean by ā3pā? Are you referring to a third-party application or something else?
2. Obtaining the installed_app_id
:
To obtain the installed_app_id
, you should look for it in the response when you receive the access token. For example, you might get a response similar to this:
{
"access_token": "EXAMPLE_ACCESS_TOKEN",
"token_type": "bearer",
"refresh_token": "EXAMPLE_REFRESH_TOKEN",
"expires_in": 86399,
"scope": "EXAMPLE_SCOPES",
"installed_app_id": "EXAMPLE_INSTALLED_APP_ID",
"access_tier": 0
}
The installed_app_id
is essential for using the Subscription APIs.
3. Notifications and OAuth-In App:
Currently, from an OAuth integration, you cannot send notifications directly to the app. Notifications are generally handled through routines or similar mechanisms. If you want to notify users when a device event occurs, you would typically need to implement routines
.
4. Subscription APIs:
You can use the Subscription APIs for OAuth-In Apps, but you must ensure that you have the correct installed_app_id
and permissions. If you are not seeing the installed_app_id
in your API responses, double-check your token and ensure you are making the correct API calls.
1 Like
yes 3p means third party application.
Thankyou for your response Mr Luis. I have below questions.
- from point 3 : By routines do you mean normally smartApps which are installed in the literal sense are capable of getting notifications? OAuth In apps do not get installed in usersā smartThings app thus cannot get notifications?
- There is mention of targer URL also in āOAuth In App typeā. I was assuming the notification of device events could be dumped on this webhook. Is it not so? Then what is the use of target URL in āOAuth In appā type.
- from point 4: subscriptions can be listed and created but device events will not be notified?
Hi @Krushnali_Tiwari ,
I apologize for the confusion in my previous response. Let me clarify your questions:
- Target URL in OAuth-In Apps:
- The Target URL specified in OAuth-In Apps is indeed used to receive subscription events. This URL should be where you want to receive events for subscribed capabilities or devices. If you are not receiving notifications, please ensure that:
- You have subscribed to the correct capabilities or devices.
- You are within the subscription limits (up to 20 subscriptions per SmartApp).
- Your Target URL is correctly configured to handle the incoming events.For more details on the subscription limits and configurations, you can refer to the following links:
- Subscriptions Documentation
- Rate Limits for Subscriptions
- Subscription APIs:
- Subscriptions can be listed and created, but device events will only be sent to the Target URL if everything is set up correctly. Ensure you are using the correct
installed_app_id
and have the right permissions.
I hope this helps clarify the situation. If you have any more questions or need further assistance, please let me know.
1 Like
Would like to mention one point for others who might see this communication
- once the OAuth In app is created in smartThings cli (with targetURL)
- register the app by āsmartthings apps:registerā.
- Registering the app means a simple confirmation of target url (done my SmartThings). After this the events are received on the targetURL.
- Cheers!
Thankyou Mr Luis
1 Like