Skip to content
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

Add cryptography as dependency (for app-based auth) #2441

Closed
jodelasur opened this issue Mar 1, 2023 · 4 comments · Fixed by #2443
Closed

Add cryptography as dependency (for app-based auth) #2441

jodelasur opened this issue Mar 1, 2023 · 4 comments · Fixed by #2443

Comments

@jodelasur
Copy link
Contributor

Using the new app-based auth results to the error below when cryptography is not installed. It should be added as a dependency of this.

Traceback (most recent call last):
  File "***", line 60, in ***
    github = Github(
  File "/usr/local/lib/python3.9/site-packages/github/MainClass.py", line 122, in __init__
    self.__requester = Requester(
  File "/usr/local/lib/python3.9/site-packages/github/Requester.py", line 332, in __init__
    self._refresh_token()
  File "/usr/local/lib/python3.9/site-packages/github/Requester.py", line 396, in _refresh_token
    self.__installation_authorization = self._get_installation_authorization()
  File "/usr/local/lib/python3.9/site-packages/github/Requester.py", line 377, in _get_installation_authorization
    integration = GithubIntegration.GithubIntegration(
  File "/usr/local/lib/python3.9/site-packages/github/GithubIntegration.py", line 52, in __init__
    jwt=self.create_jwt(),
  File "/usr/local/lib/python3.9/site-packages/github/GithubIntegration.py", line 106, in create_jwt
    encrypted = jwt.encode(payload, key=self.private_key, algorithm="RS256")
  File "/usr/local/lib/python3.9/site-packages/jwt/api_jwt.py", line 67, in encode
    return api_jws.encode(json_payload, key, algorithm, headers, json_encoder)
  File "/usr/local/lib/python3.9/site-packages/jwt/api_jws.py", line 152, in encode
    alg_obj = self.get_algorithm_by_name(algorithm_)
  File "/usr/local/lib/python3.9/site-packages/jwt/api_jws.py", line 91, in get_algorithm_by_name
    raise NotImplementedError(
NotImplementedError: Algorithm 'RS256' could not be found. Do you have cryptography installed?
@s-t-e-v-e-n-k
Copy link
Collaborator

We probably need an extra of jwt, looking at the traceback.

@EnricoMi
Copy link
Collaborator

EnricoMi commented Mar 1, 2023

@jodelasur maybe you had package jwt installed, which conflicts with PyJWT, which is a dependency of PyGithub?

If you'd uninstall jwt and reinstalled PyGithub, it should work.

@EnricoMi
Copy link
Collaborator

EnricoMi commented Mar 1, 2023

It looks like PyGithub has to depend on PyJWT[crypto] to pull in the cryptography package correctly.

So if you do a pip install "pyjwt[crypto]>=2.4.0", everything should work with 1.58.0.

@EnricoMi
Copy link
Collaborator

EnricoMi commented Mar 1, 2023

This issue has been seen in #1165 and fixed only for testing. Before, this has been addressed in #557 and #554.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants