From 22795cb14e28d5f827e1bfc42dc32e27326b4e22 Mon Sep 17 00:00:00 2001
From: SOUBHIK KUMAR MITRA <soubhikmitra98@gmail.com>
Date: Fri, 28 Mar 2025 00:49:57 +0530
Subject: [PATCH 1/4] Convert App ID to string for JWT issuer claim

Wrap self._app_id with str() in the JWT payload's "iss" field to ensure
it is always a string, addressing a potential type mismatch. This fixes
compatibility issues where downstream JWT processing expects a string
issuer, as GitHub App IDs are typically integers.
---
 github/Auth.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: pygithub-2.6.1/github/Auth.py
===================================================================
--- pygithub-2.6.1.orig/github/Auth.py
+++ pygithub-2.6.1/github/Auth.py
@@ -234,7 +234,7 @@ class AppAuth(JWT):
         assert isinstance(jwt_expiry, int), jwt_expiry
         assert Consts.MIN_JWT_EXPIRY <= jwt_expiry <= Consts.MAX_JWT_EXPIRY, jwt_expiry
 
-        self._app_id = app_id
+        self._app_id = str(app_id)
         self._sign_func = sign_func
         self._jwt_expiry = jwt_expiry
         self._jwt_issued_at = jwt_issued_at
Index: pygithub-2.6.1/tests/Authentication.py
===================================================================
--- pygithub-2.6.1.orig/tests/Authentication.py
+++ pygithub-2.6.1/tests/Authentication.py
@@ -302,8 +302,9 @@ class Authentication(Framework.BasicTest
             key=PUBLIC_KEY,
             algorithms=["RS256"],
             options={"verify_exp": False},
+            issuer=str(APP_ID),
         )
-        self.assertDictEqual(payload, {"iat": 1550055271, "exp": 1550055631, "iss": APP_ID})
+        self.assertDictEqual(payload, {"iat": 1550055271, "exp": 1550055631, "iss": str(APP_ID)})
 
     def testCreateJWTWithExpiration(self):
         auth = github.Auth.AppAuth(APP_ID, PRIVATE_KEY, jwt_expiry=120, jwt_issued_at=-30)
@@ -317,8 +318,9 @@ class Authentication(Framework.BasicTest
             key=PUBLIC_KEY,
             algorithms=["RS256"],
             options={"verify_exp": False},
+            issuer=str(APP_ID),
         )
-        self.assertDictEqual(payload, {"iat": 1550055301, "exp": 1550055391, "iss": APP_ID})
+        self.assertDictEqual(payload, {"iat": 1550055301, "exp": 1550055391, "iss": str(APP_ID)})
 
     def testUserAgent(self):
         g = github.Github(user_agent="PyGithubTester")
