Skip to content

Commit

Permalink
Fix when token fetch error
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreLobato committed Dec 12, 2024
1 parent a847817 commit 71a360a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/oceanum/cli/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,19 @@ def refresh_token(self, token: TokenResponse) -> TokenResponse:
response = self._request('POST', 'oauth/token', data=data)
return TokenResponse(domain=self.ctx.obj.domain, **response.json())

def wait_for_confirmation(self, device_code: DeviceCodeResponse) -> TokenResponse:
def wait_for_confirmation(self, device_code: DeviceCodeResponse) -> TokenResponse|None:
t0 = time.time()
token = None
while time.time() - t0 < device_code.expires_in:
try:
time.sleep(device_code.interval)
token = self.get_token(device_code.device_code)
except requests.HTTPError as e:
print(f'Error fetching auth token: {e}')
continue
else:
token.save()
break
token.save()
return token


Expand Down

0 comments on commit 71a360a

Please sign in to comment.