diff --git a/lib/IdPAccountManager/WebRequest.pm b/lib/IdPAccountManager/WebRequest.pm
index 49ffda6566f7e129690538c0c6ed0f92110d1c86..72972c3464e29a121b27a69562f4cbfd5f01bba2 100755
--- a/lib/IdPAccountManager/WebRequest.pm
+++ b/lib/IdPAccountManager/WebRequest.pm
@@ -460,7 +460,7 @@ sub req_validate_token {
         return undef;
     }
 
-    if (! $token->get('sp_entityid') eq $self->{in}->{sp_entityid}) {
+    if (! $token->sp_entityid() eq $self->{in}->{sp_entityid}) {
         push @{ $self->{out}->{errors} }, "wrong_token_for_sp";
         $self->{logger}->errorf(
             "Authentication token %s cannot be used for SP with entityid %s",