Authorization State Sync
How to Synchronize Login/Authorization in Integration with x-bees
In your application, any standard methods for user authentication can be used, just like on any regular website. However, x-bees offers integration capabilities to track authentication states and allow the user to manage them directly from x-bees.
If your application supports authorization, after sending the ready()
handshake message to x-bees, it is necessary to immediately send the current
authentication state by invoking isAuthorized()
or isNotAuthorized()
.
For the unauthorized state of integration app, it is recommended to display a welcome view where the user can sign in.
How x-bees Uses the Authorization State
-
Once x-bees receives
isNotAuthorized
, the integration will no longer be visible in the info panel interface, it won't appear in searches, and the user may receive a notification that the integration is inactive and needs activation settings. -
When the user chooses to sign in, x-bees will open a special popup in dialog mode (refer to the integration modes for details). This dialog will display your integration and it is expected sign-in page is displayed.
App Authorization Confirmed
After the user successfully completes login, notify x-bees using
Client.getInstance().isAuthorized()
, and ensure you store the session or token,
so the user remains logged in during future interactions.
Handling Login State Changes
We recommend notifying all open instances of the integration app about authorization state changes, so they can update their login state accordingly. This can be achieved using broadcast events or localStorage. The xbees-connect library provides utility functions for localStorage management:
// Save data to storage
Client.getInstance().saveToStorage('authToken', token);
// Retrieve data from storage
const token = Client.getInstance().getFromStorage('authToken');
// Delete data from storage
Client.getInstance().deleteFromStorage('authToken');
By using these functions, you can manage user sessions efficiently across all instances of your application integrated with x-bees.
Info:
If, for any reason, your application is not ready to be launched on mobile devices, we recommend sending the handshake with the"web"
parameter like this:ready("web")
. This will indicate to x-bees that the integration is intended only for the web version. Additionally, you should disable mobile platform support in the integration settings on the PBX.
Once the issues are resolved, you can remove this argument and update the PBX setting to support all platforms.