sarumont / py-trello

Python API wrapper around Trello's API
BSD 3-Clause "New" or "Revised" License
945 stars 330 forks source link

`create_hook` doesn't work when oauth is not used #299

Open yannrouillard opened 4 years ago

yannrouillard commented 4 years ago

Currently where using the TrelloClient create_hook method without oauth enabled, the method doesn't work because of a missing authentication.

See https://github.com/sarumont/py-trello/blob/master/trello/trelloclient.py#L277

        response = self.http_service.post(url, data=data, auth=self.oauth, proxies=self.proxies)

The HTTP call only include the self.oauth auth info if present but doesn't include the api key and token through query params if oauth is not used.

Note that create_hook uses not the same code as other function (because of some bugs encountered in the past), however we fully replaced it with fetch_json as a workaround without issue so maybe there is no more need for this particularity.

Code we used:

        return self.trello_client.fetch_json(
            f"tokens/{self.trello_token}/webhooks/",
            http_method="POST",
            post_args={
                "callbackURL": self.callback_url,
                "idModel": card.id,
                "description": self.callback_desc,
            }
        )