Skip to content

Commit

Permalink
fix: update pyjwt parameters to satisfy 2.x changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rmkeezer committed Jan 7, 2021
1 parent 26a42a6 commit f2d7225
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ibm_cloud_sdk_core/jwt_token_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _save_token_info(self, token_response: dict) -> None:
self.access_token = token_response.get(self.token_name)

# The time of expiration is found by decoding the JWT access token
decoded_response = jwt.decode(self.access_token, verify=False)
decoded_response = jwt.decode(self.access_token, algorithms=["RS256"], options={"verify_signature": False})
# exp is the time of expire and iat is the time of token retrieval
exp = decoded_response.get('exp')
iat = decoded_response.get('iat')
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
requests>=2.20,<3.0
python_dateutil>=2.5.3,<3.0.0
PyJWT >=1.7.1,<2.0.0
PyJWT>=2.0.0a1,<3.0.0
2 changes: 1 addition & 1 deletion test/test_base_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def get_access_token() -> str:
headers={
'kid': '230498151c214b788dd97f22b85410a5'
})
return access_token.decode('utf-8')
return access_token


@responses.activate
Expand Down
2 changes: 1 addition & 1 deletion test/test_cp4d_authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_get_token():

access_token = jwt.encode(access_token_layout,
'secret', algorithm='HS256',
headers={'kid': '230498151c214b788dd97f22b85410a5'}).decode('utf-8')
headers={'kid': '230498151c214b788dd97f22b85410a5'})
response = {
"accessToken": access_token,
"token_type": "Bearer",
Expand Down
2 changes: 1 addition & 1 deletion test/test_cp4d_token_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_request_token():

access_token = jwt.encode(access_token_layout,
'secret', algorithm='HS256',
headers={'kid': '230498151c214b788dd97f22b85410a5'}).decode('utf-8')
headers={'kid': '230498151c214b788dd97f22b85410a5'})
response = {
"accessToken": access_token,
}
Expand Down
1 change: 0 additions & 1 deletion test/test_iam_authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def test_get_token():
headers={
'kid': '230498151c214b788dd97f22b85410a5'
})
access_token = access_token.decode('utf-8')
response = {
"access_token": access_token,
"token_type": "Bearer",
Expand Down
2 changes: 1 addition & 1 deletion test/test_iam_token_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get_access_token() -> str:

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

@responses.activate
def test_request_token_auth_default():
Expand Down

0 comments on commit f2d7225

Please sign in to comment.