verifyAppAuthorization static method
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
token: the token to validate (typically a JWT).callback: a function invoked with a GemError describing the validation outcome. Typical values include:- GemError.success — token is valid.
- GemError.invalidInput — token was malformed.
- GemError.expired — token has expired.
- GemError.accessDenied — token is blacklisted or otherwise denied.
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,
);
}