/**
  * {@inheritdoc}
  */
 public function check(OAuth2Token $token, OAuth2 $configuration)
 {
     if (null === $configuration->getResourceOwnerType()) {
         return;
     }
     $result = $this->isTypeValid($configuration->getResourceOwnerType(), $token->getResourceOwner());
     if (false === $result) {
         return 'Bad resource owner type';
     }
 }
 /**
  * {@inheritdoc}
  */
 public function check(OAuth2Token $token, OAuth2 $configuration)
 {
     if (null === $configuration->getResourceOwnerType()) {
         return;
     }
     if (self::TYPE_CLIENT === $configuration->getResourceOwnerType() && $token->getResourceOwner() instanceof ClientInterface) {
         return;
     }
     if (self::TYPE_USER === $configuration->getResourceOwnerType() && $token->getResourceOwner() instanceof UserAccountInterface) {
         return;
     }
     return 'Resource owner not authorized.';
 }