fix: new token init
This commit is contained in:
parent
9cb8c63d99
commit
8dac2e528f
1 changed files with 11 additions and 4 deletions
|
|
@ -27,14 +27,21 @@ class OAuthToken:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_response(cls, response):
|
def from_response(cls, response):
|
||||||
return cls(**response.json())
|
data = response.json()
|
||||||
|
return cls(**data)
|
||||||
|
|
||||||
def __init__(self, access_token: str, refresh_token: str, scope: str, expires_at: int,
|
def __init__(self,
|
||||||
token_type: str, **etc: Optional[Any]):
|
access_token: str,
|
||||||
|
refresh_token: str,
|
||||||
|
scope: str,
|
||||||
|
token_type: str,
|
||||||
|
expires_at: Optional[int] = None,
|
||||||
|
expires_in: Optional[int] = None,
|
||||||
|
**etc: Optional[Any]):
|
||||||
self._access_token = access_token
|
self._access_token = access_token
|
||||||
self._refresh_token = refresh_token
|
self._refresh_token = refresh_token
|
||||||
self._scope = scope
|
self._scope = scope
|
||||||
self._expires_at: int = expires_at
|
self._expires_at: int = expires_at if expires_at else int(time.time() + expires_in)
|
||||||
self._token_type = token_type
|
self._token_type = token_type
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue