Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
wrappers.py24 linesDownload Raw Back to rfc6749
1import time2 3 4class OAuth2Token(dict):5    def __init__(self, params):6        if params.get('expires_at'):7            params['expires_at'] = int(params['expires_at'])8        elif params.get('expires_in'):9            params['expires_at'] = int(time.time()) + \10                                   int(params['expires_in'])11        super().__init__(params)12 13    def is_expired(self):14        expires_at = self.get('expires_at')15        if not expires_at:16            return None17        return expires_at < time.time()18 19    @classmethod20    def from_dict(cls, token):21        if isinstance(token, dict) and not isinstance(token, cls):22            token = cls(token)23        return token24 
codekingpro/portable-devtools · Team Ai