code: def verify(self, key, alg=None):
          
  
          self.verifylog = list()
          self.objects['valid'] = False
          obj = self.objects
          if 'signature' in obj:
              try:
                  self._verify(alg, key,
                               obj['payload'],
                               obj['signature'],
                               obj.get('protected', None),
                               obj.get('header', None))
                  obj['valid'] = True
              except Exception as e:  # pylint: disable=broad-except
                  self.verifylog.append('Failed: [%s]' % repr(e))
  
          elif 'signatures' in obj:
              for o in obj['signatures']:
                  try:
                      self._verify(alg, key,
                                   obj['payload'],
                                   o['signature'],
                                   o.get('protected', None),
                                   o.get('header', None))
                      # Ok if at least one verifies
                      obj['valid'] = True
                  except Exception as e:  # pylint: disable=broad-except
                      self.verifylog.append('Failed: [%s]' % repr(e))
          else:
              raise InvalidJWSSignature('No signatures availble')
  
          if not self.is_valid:
              raise InvalidJWSSignature('Verification failed for all '
                                        'signatures' + repr(self.verifylog))
docs: Verifies a JWS token.
  
          :param key: The (:class:`jwcrypto.jwk.JWK`) verification key.
          :param alg: The signing algorithm (optional). usually the algorithm
              is known as it is provided with the JOSE Headers of the token.
  
          :raises InvalidJWSSignature: if the verification fails.