From 1b61b6a9ebb6ea25e9014708c7451d35add55b3b Mon Sep 17 00:00:00 2001 From: khushal Date: Thu, 28 Nov 2024 13:07:47 +0530 Subject: [PATCH] (20241128) Scopes check added. --- api/blueprints/mail/{callback.py => oauth_callback.py} | 0 api/blueprints/mail/{oauth.py => oauth_request.py} | 0 utils_v2/goog/models/data/auth_tokens.py | 9 +++++++-- 3 files changed, 7 insertions(+), 2 deletions(-) rename api/blueprints/mail/{callback.py => oauth_callback.py} (100%) rename api/blueprints/mail/{oauth.py => oauth_request.py} (100%) diff --git a/api/blueprints/mail/callback.py b/api/blueprints/mail/oauth_callback.py similarity index 100% rename from api/blueprints/mail/callback.py rename to api/blueprints/mail/oauth_callback.py diff --git a/api/blueprints/mail/oauth.py b/api/blueprints/mail/oauth_request.py similarity index 100% rename from api/blueprints/mail/oauth.py rename to api/blueprints/mail/oauth_request.py diff --git a/utils_v2/goog/models/data/auth_tokens.py b/utils_v2/goog/models/data/auth_tokens.py index d6c4cd2..df57f53 100644 --- a/utils_v2/goog/models/data/auth_tokens.py +++ b/utils_v2/goog/models/data/auth_tokens.py @@ -207,7 +207,7 @@ class GoogleAuthTokens(BaseModel): def has_scopes(self, scopes: List[str]) -> bool: """ - Check if all the specified scopes were granted. + Checks if all the specified scopes were granted. :param scopes: The list of scopes to check. These are the permissions you need. :return: True if all specified scoped are present, else False. """ @@ -217,7 +217,12 @@ class GoogleAuthTokens(BaseModel): # Now loop through the needed scopes and check: for scope in scopes: - if scope not in self.scopes + if scope not in self.scopes: + has_scopes = False + break + + # Done here: + return has_scopes # *****************************************************************************************************************