verifyAppAuthorization static method

void verifyAppAuthorization(
  1. String token,
  2. void callback(
    1. GemError err
    )
)

Verifies an app token.

Validates the provided token and reports progress through the specified listener.

Parameters

  • IN token The token to be verified. Must be a valid JWT token.
  • IN callback An operation progress listener that handles the validation process.
    • GemError.invalidInput Triggered if the token format is invalid (e.g., not a JWT token).
    • GemError.expired Triggered if the token is expired.
    • GemError.accessDenied Triggered if the token is blacklisted (e.g., the token's jti or aud is blacklisted).
    • Other error codes may be related to the validation process and are not directly related to token validity.

Throws

  • An exception if it fails.

Implementation

static void verifyAppAuthorization(
  String token,
  void Function(GemError err) callback,
) {
  final EventDrivenProgressListener listener = EventDrivenProgressListener();
  GemKitPlatform.instance.registerEventHandler(listener.id, listener);
  listener.registerOnCompleteWithDataCallback((
    int err,
    String hint,
    Map<dynamic, dynamic> json,
  ) {
    callback(GemErrorExtension.fromCode(err));
    GemKitPlatform.instance.unregisterEventHandler(listener.id);
  });
  objectMethod(
    0,
    'SdkSettings',
    'verifyAppAuthorization',
    args: <String, dynamic>{'token': token, 'listener': listener.id},
  );
}