def bulk_refresh(self):
"""
Refreshes all refreshable tokens in the queryset.
Deletes any tokens which fail to refresh.
Deletes any tokens which are expired and cannot refresh.
"""
session = OAuth2Session(app_settings.ESI_SSO_CLIENT_ID)
auth = requests.auth.HTTPBasicAuth(app_settings.ESI_SSO_CLIENT_ID, app_settings.ESI_SSO_CLIENT_SECRET)
for model in self.filter(refresh_token__isnull=False):
try:
model.refresh(session=session, auth=auth)
except TokenError:
model.delete()
self.filter(refresh_token__isnull=True).get_expired().delete()
评论列表
文章目录