So I'm trying to add a webhook to notify me when somebody makes a push
to a repo of mine. As far as I can tell, I need to use the legacy API
to do that. I couldn't figure a way to do it with the hut CLI for
instance. I went and created a legacy oauth token, and then tried
sending my request to add a webhook:
```python
import requests
u = 'https://git.selfhosted.instance/api/~cmb/repos/my-cool-repo/webhooks'
headers = {'Authorization': 'token ' + a_32byte_hexstring}
requests.post(u, params=dict(
url='https://the-brannons.com/cgi-bin/cmb-webhook?type=git',
events='["repo:post-update"]'), headers=h)
```
And I consistently get a response with HTTP status code 500 and a JSON
payload of
{"errors": [{"reason": "Temporary authentication failure"}]}
I asked the instance admin, and he says he doesn't see anything in the
API logs.
Any help is appreciated.
-- Chris
On Mon, Jan 29, 2024 at 10:53:04AM -0800, Chris Brannon wrote:
> So I'm trying to add a webhook to notify me when somebody makes a push> to a repo of mine. As far as I can tell, I need to use the legacy API> to do that. I couldn't figure a way to do it with the hut CLI for> instance. I went and created a legacy oauth token, and then tried> sending my request to add a webhook:> > ```python> import requests> u = 'https://git.selfhosted.instance/api/~cmb/repos/my-cool-repo/webhooks'> headers = {'Authorization': 'token ' + a_32byte_hexstring}
headers
> requests.post(u, params=dict(> url='https://the-brannons.com/cgi-bin/cmb-webhook?type=git',> events='["repo:post-update"]'), headers=h)
h
> ```> > And I consistently get a response with HTTP status code 500 and a JSON> payload of> {"errors": [{"reason": "Temporary authentication failure"}]}> > I asked the instance admin, and he says he doesn't see anything in the> API logs.> > Any help is appreciated.>
My stab at it
```python
import requests
u = 'https://git.selfhosted.instance/api/~cmb/repos/my-cool-repo/webhooks'
hdrs = {'Authorization': 'token ' + a_32byte_hexstring}
requests.post(u, params=dict(
url='https://the-brannons.com/cgi-bin/cmb-webhook?type=git',
events='["repo:post-update"]'), headers=hdrs)
```
Groeten
Geert Stappers
--
Silence is hard to parse
Geert Stappers <stappers@stappers.nl> writes:
> On Mon, Jan 29, 2024 at 10:53:04AM -0800, Chris Brannon wrote:>> So I'm trying to add a webhook to notify me when somebody makes a push>> to a repo of mine. As far as I can tell, I need to use the legacy API>> to do that. I couldn't figure a way to do it with the hut CLI for>> instance. I went and created a legacy oauth token, and then tried>> sending my request to add a webhook:>> >> ```python>> import requests>> u = 'https://git.selfhosted.instance/api/~cmb/repos/my-cool-repo/webhooks'>> headers = {'Authorization': 'token ' + a_32byte_hexstring}>> headers>>>> requests.post(u, params=dict(>> url='https://the-brannons.com/cgi-bin/cmb-webhook?type=git',>> events='["repo:post-update"]'), headers=h)>> h
That was just a typo caused by me transcribing into email the thing I'd
been typing at the Python interpreter.
Thanks,
-- Chris
Following back up on this because we did discover the cause of the
temporary failures. Apparently one of the database indices was corrupt.
It was a simple fix.
-- Chris