Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Move get_request_params method to the base class
Adam Bogdał881a9cfd4dae
diff --git a/saleor/registration/test_registration.py b/saleor/registration/test_registration.pyindex 30eb410d0e..77f1336584 100644--- a/saleor/registration/test_registration.py+++ b/saleor/registration/test_registration.py@@ -64,7 +64,7 @@ def test_facebook_appsecret_proof():facebook_client = FacebookClient(local_host='localhost')facebook_client.authorizer = authorizer- data = facebook_client.get_request_params()+ data, _ = facebook_client.get_request_params()assert data['appsecret_proof'] == proofdiff --git a/saleor/registration/utils.py b/saleor/registration/utils.pyindex 9ec1c93784..8e9bc17b75 100644--- a/saleor/registration/utils.py+++ b/saleor/registration/utils.py@@ -116,13 +116,17 @@ class OAuth2Client(object):def get_user_info(self):return self.get(self.user_info_uri)- def get(self, address, params=None, authorize=True):+ def get_request_params(self, data=None, authorize=True):auth = self.authorizer if authorize else None+ return data, auth++ def get(self, address, params=None, authorize=True):+ params, auth = self.get_request_params(params, authorize)response = requests.get(address, params=params, auth=auth)return self.handle_response(response)def post(self, address, data=None, authorize=True):- auth = self.authorizer if authorize else None+ data, auth = self.get_request_params(data, authorize)response = requests.post(address, data=data, auth=auth)return self.handle_response(response)@@ -183,23 +187,14 @@ class FacebookClient(OAuth2Client):self.client_secret = settings.FACEBOOK_SECRETsuper(FacebookClient, self).__init__(*args, **kwargs)- def get_request_params(self, data=None):+ def get_request_params(self, data=None, authorize=True):data = data or {}- data.update({'appsecret_proof': hmac.new(- settings.FACEBOOK_SECRET.encode('utf8'),- msg=self.authorizer.access_token.encode('utf8'),- digestmod=hashlib.sha256).hexdigest()})- return data-- def get(self, address, params=None, authorize=True):- if authorize:- params = self.get_request_params(params)- return super(FacebookClient, self).get(address, params, authorize)-- def post(self, address, data=None, authorize=True):if authorize:- data = self.get_request_params(data)- return super(FacebookClient, self).post(address, data, authorize)+ data.update({'appsecret_proof': hmac.new(+ settings.FACEBOOK_SECRET.encode('utf8'),+ msg=self.authorizer.access_token.encode('utf8'),+ digestmod=hashlib.sha256).hexdigest()})+ return super(FacebookClient, self).get_request_params(data, authorize)def get_user_info(self):response = super(FacebookClient, self).get_user_info()