Skip to content

Commit f2d7225

Browse files
committed
fix: update pyjwt parameters to satisfy 2.x changes
1 parent 26a42a6 commit f2d7225

File tree

7 files changed

+6
-7
lines changed

7 files changed

+6
-7
lines changed

ibm_cloud_sdk_core/jwt_token_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def _save_token_info(self, token_response: dict) -> None:
6868
self.access_token = token_response.get(self.token_name)
6969

7070
# The time of expiration is found by decoding the JWT access token
71-
decoded_response = jwt.decode(self.access_token, verify=False)
71+
decoded_response = jwt.decode(self.access_token, algorithms=["RS256"], options={"verify_signature": False})
7272
# exp is the time of expire and iat is the time of token retrieval
7373
exp = decoded_response.get('exp')
7474
iat = decoded_response.get('iat')

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
requests>=2.20,<3.0
22
python_dateutil>=2.5.3,<3.0.0
3-
PyJWT >=1.7.1,<2.0.0
3+
PyJWT>=2.0.0a1,<3.0.0

test/test_base_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def get_access_token() -> str:
111111
headers={
112112
'kid': '230498151c214b788dd97f22b85410a5'
113113
})
114-
return access_token.decode('utf-8')
114+
return access_token
115115

116116

117117
@responses.activate

test/test_cp4d_authenticator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_get_token():
8585

8686
access_token = jwt.encode(access_token_layout,
8787
'secret', algorithm='HS256',
88-
headers={'kid': '230498151c214b788dd97f22b85410a5'}).decode('utf-8')
88+
headers={'kid': '230498151c214b788dd97f22b85410a5'})
8989
response = {
9090
"accessToken": access_token,
9191
"token_type": "Bearer",

test/test_cp4d_token_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_request_token():
2727

2828
access_token = jwt.encode(access_token_layout,
2929
'secret', algorithm='HS256',
30-
headers={'kid': '230498151c214b788dd97f22b85410a5'}).decode('utf-8')
30+
headers={'kid': '230498151c214b788dd97f22b85410a5'})
3131
response = {
3232
"accessToken": access_token,
3333
}

test/test_iam_authenticator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ def test_get_token():
9292
headers={
9393
'kid': '230498151c214b788dd97f22b85410a5'
9494
})
95-
access_token = access_token.decode('utf-8')
9695
response = {
9796
"access_token": access_token,
9897
"token_type": "Bearer",

test/test_iam_token_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def get_access_token() -> str:
2525

2626
access_token = jwt.encode(access_token_layout, 'secret', algorithm='HS256',
2727
headers={'kid': '230498151c214b788dd97f22b85410a5'})
28-
return access_token.decode('utf-8')
28+
return access_token
2929

3030
@responses.activate
3131
def test_request_token_auth_default():

0 commit comments

Comments
 (0)