def register_device(): devices = oauth_server.get(server_url + '/api/devices').data['objects'] print devices print devices.__class__.__name__ user_devices = [device for device in devices if device['id'] == request.form['device_id']] if len(user_devices) != 1: response = jsonify({'error': 'incorrect number of devices found for this id'}) response.status_code = (500) return response user_device = user_devices[0] print user_device utils.make_hidden_session('device', user_device) return jsonify({'objects': user_device})
def authorized(resp): if resp is None: return 'Access denied: reason=%s error=%s' % ( request.args['error_reason'], request.args['error_description'] ) print resp utils.make_hidden_session('oauth', (resp['access_token'], '')) response = oauth_server.get(server_url + '/api/user') if 'objects' not in response.data or 'id' not in response.data['objects']: return "no user found", 404 data = response.data print data utils.make_hidden_session('user_id', data['objects']['id']) auth_token = gen_salt(50) utils.make_hidden_session('auth_token', auth_token) session.permanent = True return jsonify({'objects': {'auth_token': auth_token}})