Skip to content

Commit df8307a

Browse files
committed
swap python-jose with pyjwt for jwt options
1 parent 5fffa75 commit df8307a

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

CHANGES.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Release 3.9.2
2+
- Migrate from using `python-jose` with native-python cryptographic backend to the `pyjwt` package
3+
14
# Release 3.9.1
25
- Fix a bug with SIP options in the `Opentok.dial` method
36

opentok/opentok.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import platform # user-agent
1313
from socket import inet_aton # create_session
1414
import xml.dom.minidom as xmldom # create_session
15-
from jose import jwt # _create_jwt_auth_header
15+
from jwt import encode # _create_jwt_auth_header
1616
import random # _create_jwt_auth_header
1717
import logging # logging
1818
import warnings # Native. Used for notifying deprecations
@@ -2065,7 +2065,7 @@ def _create_jwt_auth_header(self):
20652065
"jti": "{0}".format(0, random.random()),
20662066
}
20672067

2068-
return jwt.encode(payload, self.api_secret, algorithm="HS256")
2068+
return encode(payload, self.api_secret, algorithm="HS256")
20692069

20702070
def mute_all(
20712071
self, session_id: str, excludedStreamIds: Optional[List[str]]

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
import codecs
33
import os
44
import re
5-
import sys
65

76
here = os.path.abspath(os.path.dirname(__file__))
87

8+
99
# Read the version number from a source file.
1010
# Why read it, and not import?
1111
# see https://groups.google.com/d/topic/pypa-dev/0PkjVpcxTzQ/discussion
@@ -27,7 +27,7 @@ def find_version(*file_paths):
2727
with codecs.open("README.rst", encoding="utf-8") as f:
2828
long_description = f.read()
2929

30-
install_requires = ["requests", "six", "pytz", "python-jose", "rsa>=4.7"]
30+
install_requires = ["requests", "six", "pytz", "pyjwt[crypto]>=1.6.4", "rsa>=4.7"]
3131

3232
setup(
3333
name="opentok",

tests/test_custom_jwt_claims.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from opentok import Client, __version__
66
import time
7-
from jose import jwt
7+
from jwt import decode
88

99

1010
class JwtCustomClaimsTest(unittest.TestCase):
@@ -19,7 +19,7 @@ def setUp(self):
1919
def test_livetime_custom_claim(self):
2020
self.opentok.jwt_livetime = 5 # Token will expire 5 minutes in the future
2121
jwt_token = self.opentok._create_jwt_auth_header()
22-
claims = jwt.decode(jwt_token, self.api_secret, algorithms=[u("HS256")])
22+
claims = decode(jwt_token, self.api_secret, algorithms=[u("HS256")])
2323
expect(claims).to(have_key(u("exp")))
2424
expect(int(claims[u("exp")])).to(
2525
be_above(int(time.time()) + (60 * 4))

tests/validate_jwt.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from six import u
22
from expects import *
3-
from jose import jwt
3+
from jwt import decode
44
import time
55

66

77
def validate_jwt_header(self, jsonwebtoken):
8-
claims = jwt.decode(jsonwebtoken, self.api_secret, algorithms=[u("HS256")])
8+
claims = decode(jsonwebtoken, self.api_secret, algorithms=[u("HS256")])
99
expect(claims).to(have_key(u("iss")))
1010
expect(claims[u("iss")]).to(equal(self.api_key))
1111
expect(claims).to(have_key(u("ist")))

0 commit comments

Comments
 (0)