def check(token, aud, cid = nil)
      synchronize do
        payload = check_cached_certs(token, aud, cid)

        unless payload
          # no certs worked, might've expired, refresh
          if refresh_certs
            payload = check_cached_certs(token, aud, cid)

            unless payload
              raise SignatureError, 'Token not verified as issued by Google'
            end
          else
            raise CertificateError, 'Unable to retrieve Google public keys'
          end
        end

        payload
      end
    end
def check(token, aud, cid = nil)
      synchronize do
        payload = check_cached_certs(token, aud, cid)

        unless payload
          # no certs worked, might've expired, refresh
          if refresh_certs
            payload = check_cached_certs(token, aud, cid)

            unless payload
              raise SignatureError, 'Token not verified as issued by Google'
            end
          else
            raise CertificateError, 'Unable to retrieve Google public keys'
          end
        end

        payload
      end
    end
If it validates, returns a hash with the JWT payload from the ID Token.
  You have to provide an "aud" value, which must match the
  token's field with that name, and will similarly check cid if provided.

 If something fails, raises an error

 @param [String] token
   The string form of the token
 @param [String] aud
   The required audience value
 @param [String] cid
   The optional client-id ("azp" field) value

 @return [Hash] The decoded ID token