16 lines
532 B
Python
Raw Normal View History

2023-05-01 20:00:32 +09:00
from mdrsclient.api.user import UserApi
from mdrsclient.exceptions import UnauthorizedException
from mdrsclient.session import MDRSSession
def token_check(session: MDRSSession) -> None:
if session.token is not None:
if session.token.is_refresh_required:
user_api = UserApi(session)
try:
session.token = user_api.refresh(session.token)
except UnauthorizedException:
session.logout()
elif session.token.is_expired:
session.logout()