Skip to content

Commit

Permalink
delete unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
YoungWing committed Nov 10, 2022
1 parent 19c1bdf commit e3b7a34
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion aftership/hmac/hmac.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __init__(self, api_secret):

def hmac_signature(self, sign_string: str) -> str:
if self.api_secret is None:
self.api_secret = os.getenv('AFTERSHIP_API_SECRET')
self.api_secret = os.getenv('AS_API_SECRET')
signature_str = hmac.new(bytes(self.api_secret.encode()), msg=bytes(
sign_string.encode()), digestmod=hashlib.sha256).digest()
return base64.b64encode(signature_str).decode()
2 changes: 2 additions & 0 deletions aftership/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def request_with_aes_hmac256_signature(method, url, path, content_type, **kwargs
headers = kwargs.pop('headers', dict())
if headers.get(AS_API_KEY, None) is None:
headers[AS_API_KEY] = get_as_api_key()
if headers.get(AS_API_KEY, None) is None:
return

body = kwargs.get('json', None)
date, sign_string = gen_sign_string(method, path, body, headers, content_type)
Expand Down
2 changes: 1 addition & 1 deletion aftership/signstring/signstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _get_canonicalized_resource(self, raw_url: str) -> str:

def gen_sign_string(self, method: str, uri: str, body: str, as_header: dict, content_type: str) -> tuple:
# if self.api_secret is None:
# self.api_secret = os.getenv('AFTERSHIP_API_SECRET')
# self.api_secret = os.getenv('AS_API_SECRET')

canonicalized_as_headers = self._get_canonicalized_as_headers(as_header)
canonicalized_resource = self._get_canonicalized_resource(uri)
Expand Down

0 comments on commit e3b7a34

Please sign in to comment.