8000 twilio python changes for orgs api uptake · twilio/twilio-python@27dec32 · GitHub
[go: up one dir, main page]

Skip to content

Commit 27dec32

Browse files
committed
twilio python changes for orgs api uptake
1 parent 0211f23 commit 27dec32

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

twilio/authStrategy/tokenAuthStrategy.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,23 @@ def __init__(self, token_manager: TokenManager):
1515
self.lock = threading.Lock()
1616

1717
def get_auth_string(self) -> str:
18+
if self.token is None:
19+
self.fetch_token()
1820
return f"Bearer {self.token}"
1921

2022
def requires_authentication(self) -> bool:
2123
return True
2224

2325
def fetch_token(self):
26+
print(f'token is fetch_token {self.token}')
2427
if self.token is None or self.token == "" or self.is_token_expired(self.token):
2528
with self.lock:
2629
if self.token is None or self.token == "" or self.is_token_expired(self.token):
2730
self.token = self.token_manager.fetch_access_token()
2831

2932
def is_token_expired(self, token):
30-
decoded_jwt = jwt.decode(token, options={"verify_signature": True})
33+
print(f'token is {token}')
34+
decoded_jwt = jwt.decode(token, options={"verify_signature": True}, algorithms=["RS256"])
3135
expires_at = decoded_jwt.get("exp")
3236
# Add a buffer of 30 seconds
3337
buffer_seconds = 30

twilio/base/client_base.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ def request(
9696
auth_strategy = None ##Initialization
9797
if self.credential_provider:
9898
auth_strategy = self.credential_provider.to_auth_strategy()
99-
if auth_strategy.auth_type == AuthType.TOKEN:
100-
auth_strategy.fetch_token()
101-
headers["Authorization"] = auth_strategy.get_auth_string()
99+
headers["Authorization"] = auth_strategy.get_auth_string()
102100
else:
103101
auth = self.get_auth(auth)
104102

0 commit comments

Comments
 (0)
0