(20241125) Documentation added.

This commit is contained in:
2024-11-25 15:31:30 +05:30
parent 6f5c3f11a1
commit b5a4f0cd52
3 changed files with 104 additions and 23 deletions
+49 -4
View File
@@ -125,7 +125,8 @@ class OAuthBase(ABC):
@abstractmethod
async def initialize(
self,
scopes: List
scopes: List,
raise_exception = False
) -> bool:
"""
@@ -133,26 +134,70 @@ class OAuthBase(ABC):
flow that was created for an app through its Cloud Console panel.
:param scopes: The list of permissions being requested. The word 'scopes' has been borrowed from Google's OAuth
documentation (which was implemented first).
:param raise_exception: If set to True, any exception that occurs will be propagated. If set to false, any
exception that occurs will be suppressed.
:return: True if the initialization succeeded, False if it failed.
"""
pass
@abstractmethod
async def get_authorization_url(
self,
**kwargs
raise_exception = False,
**kwargs,
) -> str | None:
"""
To create an authorization URL which will be then sent to the front-end for the user to click and grant/decline
various permissions.
:param kwargs: The identifiers of the user who wants to use your service (where your service needs access to
their second-party account).
:param kwargs: The identifiers of the user who wants to use your service and any other service-specific options.
:param raise_exception: If set to True, any exception that occurs will be propagated. If set to false, any
exception that occurs will be suppressed.
:return: The authorization URL if successful, or None if failed.
"""
pass
@abstractmethod
async def get_tokens(
self,
raise_exception = False,
**kwargs
) -> dict | None:
"""
To get the tokens of a user. Plural 'tokens' because OAuth typically has one access token that expires
every-so-often, and one refresh token that grants you a new access token.
:param kwargs: The identifiers of the user who wants to use your service and any other service-specific options.
:param raise_exception: If set to True, any exception that occurs will be propagated. If set to false, any
exception that occurs will be suppressed.
:return: The tokens for the service if successful, or None if failed.
"""
pass
@abstractmethod
async def refresh_tokens(
self,
old_tokens: dict,
force_refresh = False,
raise_exception = False
) -> dict | None:
"""
To refresh the tokens of a user. Plural 'tokens' because OAuth typically has one access token that expires
every-so-often, and one refresh token that grants you a new access token.
:param old_tokens: The current set of tokens.
:param force_refresh: To force a refresh request even if the tokens haven't yet expired.
:param raise_exception: If set to True, any exception that occurs will be propagated. If set to false, any
exception that occurs will be suppressed.
:return: The same tokens if they haven't expired, refreshed tokens if the tokens have expired and were
successfully refreshed, None if the tokens have expired but could not be refreshed.
"""
pass
# *****************************************************************************************************************
# ***** ****