Token Authentication
- User can be authenticated by providing a valid user access token.
- Access Tokens are passed via a Token Provider
- Token provider can be applied to the SDK by providing during initialization.
- On initial start or when session time runs out or token is invalid, SDK will use this token provider to retrieve a new token,
– calling
provideTokenReplacement(@Nullable String oldToken, @NonNull String userIdentifier, @NonNull OnTokenProviderListener onTokenProviderListener)
Example:
InitializationBuilder builder = new InitializationBuilder(getApplicationContext(), DefaultEnvironment.BETA_SANDBOX)
.authTokenProvider(new TokenProvider() {
@Override
public void provideTokenReplacement(@Nullable String oldToken, @NonNull String userIdentifier, @NonNull OnTokenProviderListener onTokenProviderListener) {
// Sensibill SDK will make this call when token is invalid (ie, expired). Provide new Access Token here.
MyIntegrationServer.getAccessToken(new IntegrationServerListener(newAccessToken) {
if (newAccessToken != null){
// Pass new access token to SDK via onTokenProvided function in listener
onTokenProviderListener.onTokenProvided(newAccessToken);
} else {
// If unable to provide new access token, call onFailed function in listener
onTokenProviderListener.onFailed("Failed to get new Access Token");
}
})
}
}
- After attaching the token provider, the SDK can be initialized with the following:
SensibillSDK.getInstance().initialize(builder.build());
- After SDK is in initialized state, SDK can be started. For instructions on how to start SDK, go to the following link: