decode static method
Decode a token without checking its signature
Implementation
static JWT decode(String token) {
try {
final parts = token.split('.');
var header = jsonBase64.decode(base64Padded(parts[0]));
dynamic payload;
try {
payload = jsonBase64.decode(base64Padded(parts[1]));
} catch (ex) {
payload = utf8.decode(base64.decode(base64Padded(parts[1])));
}
if (header == null || header is! Map<String, dynamic>) {
return JWT(payload);
} else {
return JWT(
payload,
header: header,
);
}
} catch (ex, stackTrace) {
if (ex is Exception && ex is! JWTException) {
throw JWTUndefinedException(ex, stackTrace);
} else {
rethrow;
}
}
}