docs icon indicating copy to clipboard operation
docs copied to clipboard

Update generating-a-json-web-token-jwt-for-a-github-app.md

Open mark-mxwl opened this issue 1 year ago • 8 comments
trafficstars

Why:

Closes: #33324 Closes: #33989

What's being changed (if available, include any code snippets, screenshots, or gifs):

Updated formatting for payload JSON to return top-level JSON when decoded, as the previous version was throwing an error for some users. Header JSON moved to single line to match payload. Also removed "JWT: " from print line to avoid scripting conflicts.

Check off the following:

  • [X] I have reviewed my changes in staging, available via the View deployment link in this PR's timeline (this link will be available after opening the PR).

    • For content changes, you will also see an automatically generated comment with links directly to pages you've modified. The comment won't appear if your PR only edits files in the data directory.
  • [X] For content changes, I have completed the self-review checklist.

mark-mxwl avatar Jul 30 '24 03:07 mark-mxwl

Automatically generated comment ℹ️

This comment is automatically generated and will be overwritten every time changes are committed to this branch.

The table contains an overview of files in the content directory that have been changed in this pull request. It's provided to make it easy to review your changes on the staging site. Please note that changes to the data directory will not show up in this table.


Content directory changes

You may find it useful to copy this table into the pull request summary. There you can edit it to share links to important articles or changes and to give a high-level overview of how the changes in your pull request support the overall goals of the pull request.

Source Preview Production What Changed
apps/creating-github-apps/authenticating-with-a-github-app/generating-a-json-web-token-jwt-for-a-github-app.md fpt
ghec
ghes@ 3.13 3.12 3.11 3.10
fpt
ghec
ghes@ 3.13 3.12 3.11 3.10

fpt: Free, Pro, Team ghec: GitHub Enterprise Cloud ghes: GitHub Enterprise Server

github-actions[bot] avatar Jul 30 '24 03:07 github-actions[bot]

Thanks for fixing this! Great job!

There seem to be some shellcheck warnings left:

$ shellcheck bash.sh

In bash.sh line 5:
pem=$( cat $2 ) # file path of the private key as second argument
           ^-- SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean:
pem=$( cat "$2" ) # file path of the private key as second argument


In bash.sh line 8:
iat=$((${now} - 60)) # Issues 60 seconds in the past
       ^----^ SC2004 (style): $/${} is unnecessary on arithmetic variables.


In bash.sh line 9:
exp=$((${now} + 600)) # Expires 10 minutes in the future
       ^----^ SC2004 (style): $/${} is unnecessary on arithmetic variables.


In bash.sh line 30:
printf '%s\n' $JWT
              ^--^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean:
printf '%s\n' "$JWT"

For more information:
  https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...
  https://www.shellcheck.net/wiki/SC2004 -- $/${} is unnecessary on arithmeti...

Maybe let's fix them also.

lindhe avatar Jul 30 '24 07:07 lindhe

@mark-mxwl Thanks so much for opening a PR! I'll get this triaged for review ✨

nguyenalex836 avatar Jul 30 '24 13:07 nguyenalex836

Thx for the ShellCheck output @lindhe! While those are all valid warnings, we don't really have to worry about globbing (wildcards)/splitting (tab, space, newline) on our positional parameters, due to the type of data we're passing through. The curly braces on the expressions are optional--I kept them there for the sake of consistency and readability.

mark-mxwl avatar Jul 30 '24 19:07 mark-mxwl

Hi, thanks for the update. I ran the updated script, removing the templating, and there still seems to be an issue with the iat claim being a string:

{
  "message": "'Issued at' claim ('iat') must be an Integer representing the time that the assertion was issued",
  "documentation_url": "https://docs.github.com/rest",
  "status": "401"
}

Removing the quotes in the script solves the issue for me.

Interestingly, the same validation is not applied to the exp claim and will work as either a string or int.

brakel avatar Jul 31 '24 01:07 brakel

Thanks for catching that @brakel. Interesting re: the behavior with exp. I adjusted the script so that iat and exp values are both integers, which hopefully will resolve this.

mark-mxwl avatar Jul 31 '24 16:07 mark-mxwl

Thanks for opening a pull request! We've triaged this issue for technical review by a subject matter expert :eyes:

github-actions[bot] avatar Aug 23 '24 17:08 github-actions[bot]

Im sorry if i dit something. Im a beginner at this. Sorry. But my graphenoseOS pixel 6a is still hacked. Os it any step that can remove graphenos on my pixel?

Regards

Den fre 23 aug. 2024 19:11github-actions[bot] @.***> skrev:

Thanks for opening a pull request! We've triaged this issue for technical review by a subject matter expert 👀

— Reply to this email directly, view it on GitHub https://github.com/github/docs/pull/34134#issuecomment-2307479849, or unsubscribe https://github.com/notifications/unsubscribe-auth/BHOKRBS55IVG5FA2H5663ATZS5UM3AVCNFSM6AAAAABLVOY2TWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBXGQ3TSOBUHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Jaga416381 avatar Aug 23 '24 17:08 Jaga416381

@mark-mxwl Apologies for the delay! We recently merged a PR that I believe resolves the issue this PR is attempting to fix. Many apologies for not being able to get to this sooner 💛

I'll go ahead and close out this PR, but please feel free to reopen / ping if needed!

nguyenalex836 avatar Aug 23 '24 22:08 nguyenalex836

Np @nguyenalex836! Glad it got sorted. Appreciate the heads-up! 🙏

mark-mxwl avatar Aug 23 '24 22:08 mark-mxwl