def authenticate_by_token!(token, timestamp_grace = 600)
      # Validate that your code has provided a valid token. This does not
      # raise an AuthenticationError since passing tokens with empty secret is
      # a code error which should be fixed, not reported to the API's consumer
      if token.secret.nil? || token.secret.empty?
        raise "Provided token is missing secret"
      end

      validate_version!
      validate_timestamp!(timestamp_grace)
      validate_signature!(token)
      true
    end
def authenticate_by_token!(token, timestamp_grace = 600)
      # Validate that your code has provided a valid token. This does not
      # raise an AuthenticationError since passing tokens with empty secret is
      # a code error which should be fixed, not reported to the API's consumer
      if token.secret.nil? || token.secret.empty?
        raise "Provided token is missing secret"
      end

      validate_version!
      validate_timestamp!(timestamp_grace)
      validate_signature!(token)
      true
    end
Authenticates the request with a token

 Raises an AuthenticationError if the request is invalid.
 AuthenticationError exception messages are designed to be exposed to API
 consumers, and should help them correct errors generating signatures

 Timestamp: Unless timestamp_grace is set to nil (which allows this check
 to be skipped), AuthenticationError will be raised if the timestamp is
 missing or further than timestamp_grace period away from the real time
 (defaults to 10 minutes)

 Signature: Raises AuthenticationError if the signature does not match
 the computed HMAC. The error contains a hint for how to sign.