Skip to content

Commit

Permalink
Fix KeyError: 'expires_in'
Browse files Browse the repository at this point in the history
  • Loading branch information
TechiError committed Jan 1, 2024
1 parent c643564 commit bed02e4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bot/onedrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ async def get_access_token(self, code: str = None):
headers={"Content-Type": "application/x-www-form-urlencoded"},
data=data,
) as resp:
expiry_time = self.creds["expires_in"]
self.creds = await resp.json()
self.creds["expires_at"] = time.time() + self.creds["expires_in"]
self.creds["expires_at"] = time.time() + expiry_time
udB.set_key("OD_AUTH_TOKEN", self.creds)
await resp.release()
return self.creds
Expand All @@ -114,8 +115,9 @@ async def refresh_access_token(self):
headers={"Content-Type": "application/x-www-form-urlencoded"},
data=data,
) as resp:
expiry_time = self.creds["expires_in"]
self.creds = await resp.json()
self.creds["expires_at"] = time.time() + self.creds["expires_in"]
self.creds["expires_at"] = time.time() + expiry_time
await resp.release()
udB.set_key("OD_AUTH_TOKEN", self.creds)
return
Expand Down

0 comments on commit bed02e4

Please sign in to comment.