Skip to content

Comments

Cast GitHub app_id as string before using as iss#1307

Merged
sigmavirus24 merged 1 commit intosigmavirus24:mainfrom
8R0WNI3:main
Feb 3, 2026
Merged

Cast GitHub app_id as string before using as iss#1307
sigmavirus24 merged 1 commit intosigmavirus24:mainfrom
8R0WNI3:main

Conversation

@8R0WNI3
Copy link
Contributor

@8R0WNI3 8R0WNI3 commented Feb 2, 2026

The PyJWT library expects the issuer to be of type str and enforces it with jpadilla/pyjwt#1040. Using an integer as done before will result in TypeError: Issuer (iss) must be a string..

Before opening a new issue, please [search][] for a previously filed
issue to ensure you're not creating a duplicate.

Note Bug reports without the following will receive requests for these
details to be provided.

Version Information

  • The version of Python you're using: Python 3.13.9

  • The version of pip you used to install github3.py: pip 25.3

  • The version of github3.py, requests, uritemplate, and python-dateutil installed: github3.py 4.0.1

Minimum Reproducible Example

import cryptography.hazmat.primitives.asymmetric.rsa as rsa
import cryptography.hazmat.primitives.serialization as serialization
import github3.apps


private_key = rsa.generate_private_key(
    public_exponent=65537,
    key_size=2048,
)

private_key_pem = private_key.private_bytes(
    encoding=serialization.Encoding.PEM,
    format=serialization.PrivateFormat.PKCS8,
    encryption_algorithm=serialization.NoEncryption(),
)

github3.apps.create_token(
    private_key_pem=private_key_pem,
    app_id=12345,
)

Exception information

Traceback (most recent call last):
  File "<python-input-3>", line 1, in <module>
    github3.apps.create_token(
    ~~~~~~~~~~~~~~~~~~~~~~~~~^
        private_key_pem=private_key_pem,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        app_id=12345,
        ^^^^^^^^^^^^^
    )
    ^
  File "/opt/homebrew/lib/python3.13/site-packages/github3/apps.py", line 175, in create_token
    token = jwt.encode(
        payload={"iat": now, "exp": now + expire_in, "iss": app_id},
        key=private_key_pem,
        algorithm="RS256",
    )
  File "/opt/homebrew/lib/python3.13/site-packages/jwt/api_jwt.py", line 145, in encode
    raise TypeError("Issuer (iss) must be a string.")
TypeError: Issuer (iss) must be a string.

@8R0WNI3
Copy link
Contributor Author

8R0WNI3 commented Feb 2, 2026

Fixes #1306.

8R0WNI3 added a commit to gardener/cc-utils that referenced this pull request Feb 2, 2026
This is required as long as this upstream fix is not released yet:
sigmavirus24/github3.py#1307

Signed-off-by: Jonas Brand (8R0WNI3) <j.brand@sap.com>
8R0WNI3 added a commit to open-component-model/delivery-service that referenced this pull request Feb 2, 2026
This is required as long as this upstream fix is not released yet:
sigmavirus24/github3.py#1307

Signed-off-by: Jonas Brand (8R0WNI3) <j.brand@sap.com>
The pyjwt library expects the issuer to be of type `str` and enforces it
with jpadilla/pyjwt#1040. Using an integer as done before will result in
`TypeError: Issuer (iss) must be a string.`.

Signed-off-by: Jonas Brand (8R0WNI3) <j.brand@sap.com>
@sigmavirus24 sigmavirus24 merged commit b7cf611 into sigmavirus24:main Feb 3, 2026
12 checks passed
8R0WNI3 added a commit to open-component-model/delivery-service that referenced this pull request Feb 5, 2026
This is required as long as this upstream fix is not released yet:
sigmavirus24/github3.py#1307

Signed-off-by: Jonas Brand (8R0WNI3) <j.brand@sap.com>
8R0WNI3 added a commit to open-component-model/delivery-service that referenced this pull request Feb 5, 2026
This is required as long as this upstream fix is not released yet:
sigmavirus24/github3.py#1307

Signed-off-by: Jonas Brand (8R0WNI3) <j.brand@sap.com>
8R0WNI3 added a commit to open-component-model/delivery-service that referenced this pull request Feb 5, 2026
This is required as long as this upstream fix is not released yet:
sigmavirus24/github3.py#1307

Signed-off-by: Jonas Brand (8R0WNI3) <j.brand@sap.com>
8R0WNI3 added a commit to open-component-model/delivery-service that referenced this pull request Feb 5, 2026
This is required as long as this upstream fix is not released yet:
sigmavirus24/github3.py#1307

Signed-off-by: Jonas Brand (8R0WNI3) <j.brand@sap.com>
zkdev pushed a commit to gardener/cc-utils that referenced this pull request Feb 5, 2026
This is required as long as this upstream fix is not released yet:
sigmavirus24/github3.py#1307

Signed-off-by: Jonas Brand (8R0WNI3) <j.brand@sap.com>
zkdev pushed a commit to open-component-model/delivery-service that referenced this pull request Feb 9, 2026
This is required as long as this upstream fix is not released yet:
sigmavirus24/github3.py#1307

Signed-off-by: Jonas Brand (8R0WNI3) <j.brand@sap.com>
zkdev pushed a commit to open-component-model/delivery-service that referenced this pull request Feb 10, 2026
This is required as long as this upstream fix is not released yet:
sigmavirus24/github3.py#1307

Signed-off-by: Jonas Brand (8R0WNI3) <j.brand@sap.com>
@nebojsa-prodana
Copy link

Hello, sorry for barging in. Do we know when this will be getting released?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants