diff --git a/lib/AccountManager/App.pm b/lib/AccountManager/App.pm
index f017125004601ef4f5a411836c73cf46b8859f6a..99dc1c189a1d719fc182eb3940e076cdf4281f2d 100644
--- a/lib/AccountManager/App.pm
+++ b/lib/AccountManager/App.pm
@@ -280,9 +280,15 @@ sub req_select_sp {
         # if user is authenticated, and its IdP is found in metadata,
         # push all entities with the same organization URL in a list
         if ($ENV{HTTP_SHIB_IDENTITY_PROVIDER}) {
-            my $idp = $metadata->parse(entityid => $ENV{HTTP_SHIB_IDENTITY_PROVIDER});
+            my $idps = $metadata->parse(id => $ENV{HTTP_SHIB_IDENTITY_PROVIDER});
+            my $idp  = $idps->[0];
             if ($idp) {
-                my $organization = $idp->organization();
+                $self->{logger}->debugf(
+		    "idp %s found in federation %s metadata",
+		    $ENV{HTTP_SHIB_IDENTITY_PROVIDER},
+		    $federation
+		);
+                my $organization = $idp->{organization};
                 push @self_entities,
                     grep { $_->{organization} eq $organization }
                     @$entities;