Flutter SDK Authentication

SDK authentication is the process of verifying the identity of the SDK that is used to communicate with an external service or platform. In the case of WebEngage, authentication is required to ensure that your application is authorized to access the WebEngage API and interact with the platform.

If SDK security is enabled then the application must provide an authorization /JWT token with all the request to WebEngage API in order to access it's user’s data in WebEngage.

Initialization

To begin using the WebEngage plugin, initialize it using the following line of code:

_webEngagePlugin = new WebEngagePlugin();

User Login

To log in a user, use one of the following methods depending on whether JWT token security is enabled:

With JWT Token:

_webEngagePlugin.userLogin(userName, jwtToken);

This method requires both the userName and jwtToken to be passed.

Without JWT Token:

_webEngagePlugin.userLogin(userName);

This method is used when JWT token security is not enabled, and only the userName needs to be passed.

Token Invalidated Callback

If the JWT token expires or becomes invalid, you can set a callback function to handle this scenario:

_webEngagePlugin.tokenInvalidatedCallback(_onTokenInvalidated);

Update Secure Token

To update the JWT token for a user, especially in cases where the token is invalid or expired, use the following method:

_webEngagePlugin.setSecureToken(userName, jwtToken);

This method updates the jwtToken for the specified userName.