Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
libuke committed Jun 11, 2023
1 parent a87e3a2 commit 3124bc7
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions aliyundrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ def handle_error(error_message: str) -> AliyundriveInfo:
try:
flag, user_name, access_token, message = self._get_access_token(token)
if not flag:
return handle_error(info, f'get_access_token error: {message}')
return handle_error(f'get_access_token error: {message}')

flag, signin_count, message = self._check_in(access_token)
if not flag:
return handle_error(info, f'check_in error: {message}')
return handle_error(f'check_in error: {message}')

flag, message = self._get_reward(access_token, signin_count)
if not flag:
return handle_error(info, f'get_reward error: {message}')
return handle_error(f'get_reward error: {message}')

info.success = True
info.user_name = user_name
Expand All @@ -61,7 +61,6 @@ def _get_access_token(self, token: str) -> tuple[bool, str, str, str]:
payload = {'grant_type': 'refresh_token', 'refresh_token': token}

response = requests.post(url, json=payload, timeout=5)
response.raise_for_status()
data = response.json()

if 'code' in data and data['code'] in ['RefreshTokenExpired', 'InvalidParameter.RefreshToken']:
Expand All @@ -88,7 +87,6 @@ def _check_in(self, access_token: str) -> tuple[bool, int, str]:
headers = {'Authorization': f'Bearer {access_token}'}

response = requests.post(url, json=payload, params=params, headers=headers, timeout=5)
response.raise_for_status()
data = response.json()

if 'success' not in data:
Expand All @@ -115,7 +113,6 @@ def _get_reward(self, access_token: str, sign_day: int) -> tuple[bool, str]:
headers = {'Authorization': f'Bearer {access_token}'}

response = requests.post(url, json=payload, params=params, headers=headers, timeout=5)
response.raise_for_status()
data = response.json()

if 'result' not in data:
Expand Down

0 comments on commit 3124bc7

Please sign in to comment.