Advertisement
Guest User

Untitled

a guest
Jul 15th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. def request (self, path, type = 'public', method = 'GET', params = {}, headers = None, body = None):
  2.         request = '/' + self.implode_params (path, params)
  3.         url = self.urls['api'] + request
  4.         query = self.omit (params, self.extract_params (path))
  5.         if type == 'public':
  6.             if query:
  7.                 url += '?' + _urlencode.urlencode (query)
  8.         else:
  9.             nonce = str (self.nonce ())
  10.             if query:
  11.                 body = self.json (query)
  12.             what = nonce + method + request + (body or '')
  13.             secret = base64.b64decode (self.secret)
  14.             signature = self.hash (what, secret, hashlib.sha256, 'binary')
  15.             headers = {
  16.                 'CB-ACCESS-KEY': self.apiKey,
  17.                 'CB-ACCESS-SIGN': base64.b64encode (signature),
  18.                 'CB-ACCESS-TIMESTAMP': nonce,
  19.                 'CB-ACCESS-PASSPHRASE': self.password,
  20.             }
  21.         return self.fetch (url, method, headers, body)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement