Exemplo n.º 1
0
def fetch_server_data():
    ''' download categories and addon version'''
    user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
    url = paths.BLENDERKIT_ADDON_URL
    api_key = user_preferences.api_key
    # version_checker.check_version_thread(url, api_key, blenderkit)
    if user_preferences.enable_oauth:
        bkit_oauth.refresh_token_thread()
    get_profile()
    categories.fetch_categories_thread(api_key)
Exemplo n.º 2
0
def check_errors(rdata):
    if rdata.get('statusCode') == 401:
        if rdata.get('detail') == 'Invalid token.':
            user_preferences = bpy.context.preferences.addons[
                'blenderkit'].preferences
            if user_preferences.api_key != '':
                if user_preferences.enable_oauth:
                    bkit_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, ''
Exemplo n.º 3
0
def check_errors(rdata):
    if rdata.get('statusCode') == 401:
        utils.p(rdata)
        if rdata.get('detail') == 'Invalid token.':
            user_preferences = bpy.context.preferences.addons[
                'blenderkit'].preferences
            if user_preferences.api_key != '':
                if user_preferences.enable_oauth:
                    bkit_oauth.refresh_token_thread()
                return False, rdata.get('detail')
            return False, 'Use login panel to connect your profile.'
    return True, ''
Exemplo n.º 4
0
def fetch_server_data():
    ''' download categories and addon version'''
    if not bpy.app.background:
        user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
        api_key = user_preferences.api_key
        # Only refresh new type of tokens(by length), and only one hour before the token timeouts.
        if user_preferences.enable_oauth and \
                len(user_preferences.api_key) < 38 and \
                user_preferences.api_key_timeout < time.time() + 3600:
            bkit_oauth.refresh_token_thread()
        if api_key != '':
            get_profile()
        categories.fetch_categories_thread(api_key)
Exemplo n.º 5
0
def fetch_server_data():
    ''' download categories , profile, and refresh token if needed.'''
    if not bpy.app.background:
        user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
        api_key = user_preferences.api_key
        # Only refresh new type of tokens(by length), and only one hour before the token timeouts.
        if user_preferences.enable_oauth and \
                len(user_preferences.api_key) < 38 and len(user_preferences.api_key) > 0 and \
                user_preferences.api_key_timeout < time.time() + 3600:
            bkit_oauth.refresh_token_thread()
        if api_key != '' and bpy.context.window_manager.get('bkit profile') == None:
            get_profile()
        if bpy.context.window_manager.get('bkit_categories') is None:
            categories.fetch_categories_thread(api_key)