def get_smart_client(): '''Initializes and returns a new SMART Client Expects an OAUTH header as a REST parameter ''' smart_oauth_header = web.input().oauth_header smart_oauth_header = urllib.unquote(smart_oauth_header) oa_params = oauth.parse_header(smart_oauth_header) SMART_SERVER_PARAMS['api_base'] = oa_params['smart_container_api_base'] SMART_SERVER_OAUTH['consumer_key'] = oa_params['smart_app_id'] oa_params = oauth.parse_header(smart_oauth_header) resource_tokens = { 'oauth_token': oa_params['smart_oauth_token'], 'oauth_token_secret': oa_params['smart_oauth_token_secret'] } ret = SmartClient(SMART_SERVER_OAUTH['consumer_key'], SMART_SERVER_PARAMS, SMART_SERVER_OAUTH, resource_tokens) ret.record_id = oa_params['smart_record_id'] ret.user_id = oa_params['smart_user_id'] ret.smart_app_id = oa_params['smart_app_id'] return ret
def get_smart_client(): """Initializes and returns a new SMART Client Expects an OAUTH header as a REST parameter """ smart_oauth_header = web.input().oauth_header smart_oauth_header = urllib.unquote(smart_oauth_header) oa_params = oauth.parse_header(smart_oauth_header) SMART_SERVER_PARAMS["api_base"] = oa_params["smart_container_api_base"] SMART_SERVER_OAUTH["consumer_key"] = oa_params["smart_app_id"] oa_params = oauth.parse_header(smart_oauth_header) resource_tokens = { "oauth_token": oa_params["smart_oauth_token"], "oauth_token_secret": oa_params["smart_oauth_token_secret"], } ret = SmartClient(SMART_SERVER_OAUTH["consumer_key"], SMART_SERVER_PARAMS, SMART_SERVER_OAUTH, resource_tokens) ret.record_id = oa_params["smart_record_id"] ret.user_id = oa_params["smart_user_id"] ret.smart_app_id = oa_params["smart_app_id"] return ret
def get_smart_client(): '''Initializes and returns a new SMART Client Expects an OAUTH header as a REST parameter ''' smart_oauth_header = web.input().oauth_header smart_oauth_header = urllib.unquote(smart_oauth_header) oa_params = oauth.parse_header(smart_oauth_header) SMART_SERVER_PARAMS['api_base'] = oa_params['smart_container_api_base'] SMART_SERVER_OAUTH['consumer_key'] = oa_params['smart_app_id'] oa_params = oauth.parse_header(smart_oauth_header) resource_tokens={'oauth_token': oa_params['smart_oauth_token'], 'oauth_token_secret':oa_params['smart_oauth_token_secret']} ret = SmartClient(SMART_SERVER_OAUTH['consumer_key'], SMART_SERVER_PARAMS, SMART_SERVER_OAUTH, resource_tokens) ret.record_id=oa_params['smart_record_id'] ret.user_id=oa_params['smart_user_id'] ret.smart_app_id=oa_params['smart_app_id'] return ret
def get_smart_client(authorization_header, resource_tokens=None): oa_params = oauth.parse_header(authorization_header) resource_tokens={'oauth_token': oa_params['smart_oauth_token'], 'oauth_token_secret':oa_params['smart_oauth_token_secret']} ret = SmartClient(SMART_SERVER_OAUTH['consumer_key'], SMART_SERVER_PARAMS, SMART_SERVER_OAUTH, resource_tokens) ret.record_id=oa_params['smart_record_id'] return ret
def get_smart_client(authorization_header, resource_tokens=None): oa_params = oauth.parse_header(authorization_header) resource_tokens = { 'oauth_token': oa_params['smart_oauth_token'], 'oauth_token_secret': oa_params['smart_oauth_token_secret'] } ret = SmartClient(SMART_SERVER_OAUTH['consumer_key'], SMART_SERVER_PARAMS, SMART_SERVER_OAUTH, resource_tokens) ret.record_id = oa_params['smart_record_id'] return ret
def _get_smart_client(smart_oauth_header): if smart_oauth_header == '': return "No smart_oauth_header" """Convenience function to initialize a new SmartClient""" try: smart_oauth_header = urllib.unquote(smart_oauth_header) except: return "Couldn't find a parameter to match the name 'oauth_header'" oa_params = oauth.parse_header(smart_oauth_header) # This is how we know... # 1. what container we're talking to try: SMART_SERVER_PARAMS['api_base'] = oa_params['smart_container_api_base'] #SMART_SERVER_PARAMS['api_base'] = 'http://sandbox-api.smartplatforms.org' except: return "Couldn't find 'smart_contianer_api_base' in %s" % smart_oauth_header # 2. what our app ID is try: SMART_SERVER_OAUTH['consumer_key'] = oa_params['smart_app_id'] except: return "Couldn't find 'smart_app_id' in %s" % smart_oauth_header # (For demo purposes, we're assuming a hard-coded consumer secret, but # in real life we'd look this up in some config or DB now...) resource_tokens = { 'oauth_token': oa_params['smart_oauth_token'], 'oauth_token_secret': oa_params['smart_oauth_token_secret'] } ret = SmartClient( SMART_SERVER_OAUTH['consumer_key'], SMART_SERVER_PARAMS, SMART_SERVER_OAUTH, resource_tokens ) ret.record_id = oa_params['smart_record_id'] return ret