verifyToken method
Implementation
@override
FutureOr<AccessToken> verifyToken(String token) async {
var parts = token.split(".");
if (parts.length != 3) {
throw UnauthorizedException();
}
var headerText = parts[0];
var payloadText = parts[1];
var hashBase64 = parts[2];
var calcHash = await crypto
.calculateSha256Mac(utf8.encode("$headerText.$payloadText"));
var calcHashBase64 = base64Url.encode(calcHash);
if (calcHashBase64 != hashBase64) {
throw UnauthorizedException();
}
return AccessToken.fromMap(
json.decode(utf8.decode(base64Url.decode(payloadText))));
}