Each integrated app has an internal app state set in Cloudbeds. State indicates whether there are active API sessions and can be used to cancel the API sessions. To set app state use /postAppState method. To read app state use /getAppState method or subscribe to the webhook for the appstate_change.
Possible app states are:
-
enabled
- Active API sessions, user authorized the app. -
pending
- Authorization in progress. -
disabled
- No active API sessions.
App state controls the Call to Action Button on the app page in Cloudbeds Marketplace.
Connecting
On initial authentication flow, when a user approves the connection to the app Cloudbeds will automatically set app state to enabled
.
If your app has some sort of intermediary steps before the app should be enabled, you must set state to pending
. More information on how to do so, see our /postAppState in our API document.
Disconnecting
Once a user disconnects your app, you must immediately terminate the API sessions on your end if disconnection occurs on Cloudbeds Marketplace.
- To know if a user uninstalled/disconnected the app in Cloudbeds subscribe to the
integration
webhook with actionappstate_changed
. Webhook will notify you every time the app state has changed. - Or you can send a request to /getAppState. If it returns an error (view examples below), the connection may be terminated on your end too.
- Webhook subscriptions will be automatically deleted as soon as the user disconnects your App.
If there is a possibility to disconnect the integration in your app's UI you must send /postAppState
- Send /postAppState with parameter
app_state=disabled
when user decides to disconnect on your end. - Upon setting app state to
disabled
, all sessions are terminated and no more calls are able to occur.
NOTE: To be able to access and modify anything via API once again, the user must install (authorize) the app again.
API key revoked:
{ "type": "unauthorized", "title": "Unauthorized", "status": 401, "detail": "401 UNAUTHORIZED"}
For refresh token flow:
{ "error": "invalid_request", "message": "The refresh token is invalid." }
For other calls:
{
"error": "access_denied",
"message": "The resource owner or authorization server denied the request."
}
1. Marketplace - Your app's landing page
Go to your app's page in the Cloudbeds test account. While in development you won't be able to access it through the Marketplace so ask us for a direct link.
When you change the app state by calling /postAppState the button will change to either Login (app_state=enabled) or Connect App (app_sate=disabled).
2. Manage apps page
On the Manage apps page, you can see your app listed only when there are active API sessions or app_state=enabled
.
So when you change the app state to disabled, your app shouldn't be visible on this page.
Comments
0 comments
Please sign in to leave a comment.