BlenderKit: Re-login when a blender session is longer than token life.

This should happen very rarely, when e.g. run on a server for a year or so.
This commit is contained in:
Vilem Duha 2019-05-09 11:21:30 +02:00
parent 06ecc07ed0
commit 3c3283c92b
1 changed files with 3 additions and 1 deletions

View File

@ -59,13 +59,15 @@ import bpy
search_start_time = 0
prev_time = 0
def check_errors(rdata):
if rdata.get('statusCode') == 401:
if rdata.get('detail') == 'Invalid token.':
# reset the api key, so it can be requested again.
# user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
# user_preferences.api_key = ''
if user_preferences.api_key != '':
oauth.refresh_token_thread()
return False, "You've been logged out. Logging in...."
return False, 'Missing or wrong api_key in addon preferences'
return True, ''