-
Notifications
You must be signed in to change notification settings - Fork 59.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to generate valid JWT using Bash example #33324
Comments
Thanks for opening this issue. A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines. |
@lindhe Thanks so much for opening an issue! I'll get this triaged for review ✨ |
Thanks for this issue! You or anyone else is welcome to open a PR to fix/improve this example. |
Thanks for saying. I tried fixing it, but couldn't figure it out. Do you have a spec for the JWT, like which fields are required and what to include in the hash? |
I have used Refs: Is this correct approach? Please advise. |
I believe that may be different for different versions of GitHub Enterprise. In Enterprise Cloud they seem to use |
Thank you @lindhe for raising this issue, and for providing such helpful info to diagnose the problem! 🙌 When I wrote this script initially, I don't recall there being any issues with JSON decoding. However, I was able to reproduce your error quite easily. After some additional testing, the culprit revealed itself: the variables in the payload JSON were missing an extra set of quotes. Now you'll see the "eyJ0..." you're accustomed to seeing at the top of the token. I've made a few adjustments to the script--see PR #34134--and all should be working seamlessly. Furthermore, I agree that the "JWT: " included in the print line is unnecessary, and may lead to conflicts for certain users. |
Code of Conduct
What article on docs.github.com is affected?
https://docs.github.com/en/enterprise-server@3.10/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-json-web-token-jwt-for-a-github-app#example-using-bash-to-generate-a-jwt
What part(s) of the article would you like to see updated?
The Bash example for generating a JWT does not seem to work.
I'm working with a GitHub Enterprise server version
3.10.12
.Current behavior
Using some censored values here, but to illustrate what the current behavior is when I run it:
Some notes
One thing that immediately sticks out to me is that the JWT does not start with
eyJ0
like I'm used to seeing, but insteadewog
. Turns out that's because the script keeps some newlines in the JSON:I'm not sure if that is legal. Maybe it is.
Additional information
If we can change the script to output
eyJhbGci[…]
instead ofJWT: eyJhbGci[…]
, I think that would be very useful. Makes it much easier to use that in a script when a JWT is required.There are also some warnings from ShellCheck that we may want to fix while we're at it:
The text was updated successfully, but these errors were encountered: