Skip to content

fix python example in generating-a-json-web-token-jwt-for-a-github-app #39409

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ puts jwt
import sys
import time

import jwt
from jwt import JWT, jwk_from_pem


# Get PEM file path
Expand All @@ -101,7 +101,7 @@ else:

# Open PEM
with open(pem, 'rb') as pem_file:
signing_key = pem_file.read()
signing_key = jwk_from_pem(pem_file.read())

payload = {
# Issued at time
Expand All @@ -115,7 +115,8 @@ payload = {
}

# Create JWT
encoded_jwt = jwt.encode(payload, signing_key, algorithm='RS256')
instance = JWT()
Copy link
Preview

Copilot AI Jul 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter name change from 'algorithm' to 'alg' should be documented or explained in the surrounding text to help users understand why this change was made, especially since this differs from the previous API.

Suggested change
instance = JWT()
instance = JWT()
# The 'alg' parameter specifies the algorithm used for signing the JWT.
# It corresponds to the 'algorithm' parameter in the previous API.

Copilot uses AI. Check for mistakes.

This comment was marked as spam.

This comment was marked as spam.

encoded_jwt = instance.encode(payload, signing_key, alg='RS256')

print(f"JWT: {encoded_jwt}")
```
Expand Down
Loading