✅ Can't use `gh webhooks forward`: "Error: you must be authenticated to run this command"
I'm trying to forward github webhooks to a local server for testing purposes, following https://docs.github.com/en/webhooks-and-events/webhooks/receiving-webhooks-with-the-github-cli. I've logged in via
gh auth login
, and requested proper scopes:
but when I try to run the command to forward webhooks:
What gives? Wasn't sure where I could possibly ask since there isn't exactly a github CLI discord server I'm aware of, and this place is full of developers...
(And yes, I've verified the account I logged in as has proper permissions for the organization. I created the org with that account)11 Replies
oh, I think it's because I'm trying to use a GH App's webhook.
Actually, scratch that, that's not the issue - it would simply not push to the webhook at all in this case, not fail to authenticate.
is there a
verbose
version so you can see where it's trying to Reach?closest I could find is a mention that one can set
GH_DEBUG=1
. Didn't change anything.Through the glory of open source, I found https://github.com/cli/gh-webhook/blob/main/webhook/forward.go#L74
GitHub
gh-webhook/forward.go at main · cli/gh-webhook
Contribute to cli/gh-webhook development by creating an account on GitHub.
But it's not really making sense or helpful to me, but I'll dig some more to see what it's looking for and why this "token" is empty despite being authenticated
Tried to logout and back in? 😂
yep. I followed the rabbit hole to see where it's trying to get the token from and ended up here: https://github.com/cli/go-gh/blob/trunk/pkg/auth/auth.go#L35
GitHub
go-gh/auth.go at trunk · cli/go-gh
A Go module for interacting with gh and the GitHub API from the command line. - go-gh/auth.go at trunk · cli/go-gh
It tries to get a token from
$GITHUB_TOKEN
, then tries to get a token from the gh auth token
command by looking up where gh.exe
is via $GH_PATH
set both of those envvars, even restarted the terminal since I know that's required after mucking around with envvars
still fookin' nothing.
oh well, I filed an issue. I'm not sure if it's a bug with gh-webhooks or gh-cli itselfGj on finding all that out tho.
update: I was able to actually make it work by setting
$GITHUB_TOKEN
in my environment variables page. A temporary set GITHUB_TOKEN=xxx
didn't work for some reason, I'm guessing that's invalid syntax for powershell, though I didn't get any errors