C
C#16mo ago
Kiel

✅ 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:
> gh auth status
+github.com
+ ✓ Logged in to github.com as XXXXXXXXXXXX (keyring)
+ ✓ Git operations for github.com configured to use https protocol.
+ ✓ Token: gho_************************************
+ ✓ Token scopes: admin:org_hook, gist, read:org, repo, workflow
> gh auth status
+github.com
+ ✓ Logged in to github.com as XXXXXXXXXXXX (keyring)
+ ✓ Git operations for github.com configured to use https protocol.
+ ✓ Token: gho_************************************
+ ✓ Token scopes: admin:org_hook, gist, read:org, repo, workflow
but when I try to run the command to forward webhooks:
> gh webhook forward --org=FooOrg --events=issues --url="https://localhost:44322/api/github/webhooks"
-Error: you must be authenticated to run this command
> gh webhook forward --org=FooOrg --events=issues --url="https://localhost:44322/api/github/webhooks"
-Error: you must be authenticated to run this command
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
Kiel
Kiel16mo ago
oh, I think it's because I'm trying to use a GH App's webhook. clueless
Kiel
Kiel16mo ago
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.
Nergy101
Nergy10116mo ago
is there a verbose version so you can see where it's trying to Reach?
Kiel
Kiel16mo ago
closest I could find is a mention that one can set GH_DEBUG=1. Didn't change anything.
Kiel
Kiel16mo ago
GitHub
gh-webhook/forward.go at main · cli/gh-webhook
Contribute to cli/gh-webhook development by creating an account on GitHub.
Kiel
Kiel16mo ago
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
Nergy101
Nergy10116mo ago
Tried to logout and back in? 😂
Kiel
Kiel16mo ago
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
Kiel
Kiel16mo ago
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 itself
Nergy101
Nergy10116mo ago
Gj on finding all that out tho.
Kiel
Kiel16mo ago
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