code: def sign(self, consumer_secret, method, url, oauth_token_secret=None,
               **params):
          
          # build the url the same way aiohttp will build the query later on
          # cf https://github.com/KeepSafe/aiohttp/blob/master/aiohttp/client.py#L151
          # and https://github.com/KeepSafe/aiohttp/blob/master/aiohttp/client_reqrep.py#L81
          url = yarl.URL(url).with_query(sorted(params.items()))
          url, params = str(url).split('?', 1)
          method = method.upper()
  
          signature = b"&".join(map(self._escape, (method, url, params)))
  
          key = self._escape(consumer_secret) + b"&"
          if oauth_token_secret:
              key += self._escape(oauth_token_secret)
  
          hashed = hmac.new(key, signature, sha1)
          return base64.b64encode(hashed.digest()).decode()
docs: Create a signature using HMAC-SHA1.