verifyAppAuthorization static method

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

Validates an application authorization token and reports the result via a callback.

The validation process is asynchronous; the provided callback is invoked once validation completes with a GemError that indicates the result.

Parameters

Example

SdkSettings.verifyAppAuthorization(token, (status) {
  switch (status) {
    case GemError.success:
      print('The token is set and is valid.');
      break;
    case GemError.invalidInput:
      print('The token is invalid.');
      break;
    case GemError.expired:
      print('The token is expired.');
      break;
    case GemError.accessDenied:
      print('The token is blacklisted.');
      break;
    default:
      print('Other error regarding token validation : $status.');
      break;
  }
});

Implementation

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