def get_api(request=None): api = IndivoClient(SERVER_PARAMS, CONSUMER_PARAMS) if request: api.update_token(request.session.get('oauth_token_set')) return api
def get_indivo_client(request, with_session_token=True): server_params = {"api_base": settings.INDIVO_SERVER_LOCATION, "authorization_base": settings.INDIVO_UI_SERVER_BASE} consumer_params = settings.INDIVO_SERVER_OAUTH token = request.session['access_token'] if with_session_token else None client = IndivoClient(server_params, consumer_params, resource_token=token) return client