Skip to content

Commit

Permalink
Specify that gidgethub requires PyJWT >= 2.0.0. (#147)
Browse files Browse the repository at this point in the history
* Specify that gidgethub requires PyJWT >= 2.0.0.

Co-authored-by: Brett Cannon <brett@python.org>
  • Loading branch information
Mariatta and brettcannon committed Jan 5, 2021
1 parent a77f59a commit dcf63ed
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Changelog
(`Issue #74 <https://github.com/brettcannon/gidgethub/issues/74>`_).
- Fix mypy errors in ``gidgethub.httpx.GitHubAPI._request``
(`Issue #133 <https://github.com/brettcannon/gidgethub/issues/133>`_).
- Make the minimum version of PyJWT be v2.0.0.

4.2.0
-----
Expand Down
3 changes: 1 addition & 2 deletions gidgethub/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ def get_jwt(*, app_id: str, private_key: str) -> str:
"""Construct the JWT (JSON Web Token), used for GitHub App authentication."""
time_int = int(time.time())
payload = {"iat": time_int, "exp": time_int + (10 * 60), "iss": app_id}
encoded = jwt.encode(payload, private_key, algorithm="RS256")
bearer_token = encoded.decode("utf-8")
bearer_token = jwt.encode(payload, private_key, algorithm="RS256")

return bearer_token

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ author = "Brett Cannon"
author-email = "brett@python.org"
requires = [
"uritemplate>=3.0.1",
"PyJWT[crypto]"
"PyJWT[crypto]>=2.0.0"
]
requires-python = ">=3.6"
license = "Apache"
Expand Down
4 changes: 1 addition & 3 deletions tests/test_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ def test_get_jwt(self, time_mock):
"iss": app_id,
}

assert result == jwt.encode(
expected_payload, private_key, algorithm="RS256"
).decode("utf-8")
assert result == jwt.encode(expected_payload, private_key, algorithm="RS256")

@pytest.mark.asyncio
async def test_get_installation_access_token(self):
Expand Down

0 comments on commit dcf63ed

Please sign in to comment.