Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion src/githubapp/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,14 @@ def _create_jwt(self, expiration=60):
:param expiration: int
:return string:
"""
Comment thread
primetheus marked this conversation as resolved.
if self.id is None:
raise GitHubAppError(
message="GitHub App ID (github_app_id) is not configured; cannot generate JWT.",
status=None,
data=None,
)
now = int(time.time())
payload = {"iat": now, "exp": now + expiration, "iss": self.id}
payload = {"iat": now, "exp": now + expiration, "iss": str(self.id)}
encrypted = jwt.encode(payload, key=self.key, algorithm="RS256")

if isinstance(encrypted, bytes):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def test_create_jwt_payload_structure(self, mock_time, mock_jwt):
github_app = GitHubApp(github_app_id=123, github_app_key=b"test_key")
github_app._create_jwt(expiration=300)

expected_payload = {"iat": 1640995200, "exp": 1640995200 + 300, "iss": 123}
expected_payload = {"iat": 1640995200, "exp": 1640995200 + 300, "iss": "123"}
mock_jwt.encode.assert_called_once_with(
expected_payload, key=b"test_key", algorithm="RS256"
)
Expand Down
Loading