-
Notifications
You must be signed in to change notification settings - Fork 773
feat: Organizations Api uptake for twilio-python #815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
b4c5734
feat: oauth sdk implementation (#799)
manisha1997 3e246e4
Python Orgs Api Changes
AsabuHere 8395487
removing unwanted logs
AsabuHere bc5c16b
removing unwanted logs
AsabuHere a66f9e9
removing unwanted logs
AsabuHere b5a6490
removing unwanted logs
AsabuHere fac26ee
Fixing token fetch flow
AsabuHere 15e15c0
twilio python changes for orgs api uptake
AsabuHere 7b07ba7
twilio python changes for orgs api uptake
AsabuHere af11fd2
Update test_cluster.py
AsabuHere 661785d
Update test_cluster.py
AsabuHere 6a8c2d8
twilio python changes for orgs api uptake
AsabuHere 1ba2f9b
twilio python changes for orgs api uptake
AsabuHere 98708f0
twilio python changes for orgs api uptake
AsabuHere d78d5d5
twilio python changes for orgs api uptake
AsabuHere 7bdf1b5
Merge branch 'main' into asabu_Python_changes
AsabuHere bc77770
twilio python changes for orgs api uptake
AsabuHere 0211f23
twilio python changes for orgs api uptake
AsabuHere 27dec32
twilio python changes for orgs api uptake
AsabuHere 2959689
twilio python changes for orgs api uptake
AsabuHere b973065
Uptake of review comments
AsabuHere ceebd46
modified error messages
AsabuHere 35b5015
Uptake of review comments
AsabuHere 76fecab
Merge branch 'main' into asabu_Python_changes
AsabuHere e9eaa72
Organization api uptake changes
AsabuHere 1c8420c
Organization api uptake changes
AsabuHere 644f94b
Organization api uptake changes
AsabuHere 66f3e28
Organization api uptake changes
AsabuHere 88f6623
removing accept headers for delete operation
AsabuHere 630c28c
Removing unwanted code
AsabuHere 26ee4d3
Merge branch 'main' into asabu_Python_changes
AsabuHere ddb336b
Modified generated files
AsabuHere d79366e
removing unwamted logs
AsabuHere 824ed9f
Formatting changes
AsabuHere 3670f03
make prettier run
AsabuHere File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Uptake of review comments
- Loading branch information
commit 35b5015909953ee62871e8ce03036fae647ee4df
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,7 @@ | |
self.logger = logging.getLogger(__name__) | ||
|
||
def get_auth_string(self) -> str: | ||
if self.token is None: | ||
self.fetch_token() | ||
self.fetch_token() | ||
return f"Bearer {self.token}" | ||
|
||
def requires_authentication(self) -> bool: | ||
|
@@ -28,15 +27,23 @@ | |
def fetch_token(self): | ||
self.logger.info("New token fetched for accessing organization API") | ||
if self.token is None or self.token == "" or self.is_token_expired(self.token): | ||
with self.lock: | ||
with self.lock: | ||
if self.token is None or self.token == "" or self.is_token_expired(self.token): | ||
self.token = self.token_manager.fetch_access_token() | ||
|
||
def is_token_expired(self, token): | ||
print(f'token is {token}') | ||
decoded_jwt = jwt.decode(token, options={"verify_signature": True}, algorithms=["RS256"]) | ||
expires_at = decoded_jwt.get("exp") | ||
# Add a buffer of 30 seconds | ||
buffer_seconds = 30 | ||
buffer_expires_at = expires_at - buffer_seconds | ||
return buffer_expires_at < datetime.datetime.now().timestamp() | ||
try: | ||
decoded = jwt.decode(token, options={"verify_signature": False}) | ||
exp = decoded.get('exp') | ||
|
||
if exp is None: | ||
return True # No expiration time present, consider it expired | ||
|
||
|
||
# Check if the expiration time has passed | ||
return datetime.fromtimestamp(exp) < datetime.utcnow() | ||
|
||
except jwt.DecodeError: | ||
return True # Token is invalid | ||
except Exception as e: | ||
print(f"An error occurred: {e}") | ||
return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.