Skip to content

Commit 55e8e4a

Browse files
authored
Merge pull request #192 from Myxomatosis5/patch-1
Fixed websocket authentication
2 parents fe727f5 + 14a88c3 commit 55e8e4a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

gdax/websocket_client.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,15 @@ def _connect(self):
6262

6363
if self.auth:
6464
timestamp = str(time.time())
65-
message = timestamp + 'GET' + '/users/self'
66-
sub_params.update(get_auth_headers(timestamp, message, self.api_key, self.api_secret, self.api_passphrase))
65+
message = timestamp + 'GET' + '/users/self/verify'
66+
message = message.encode('ascii')
67+
hmac_key = base64.b64decode(self.api_secret)
68+
signature = hmac.new(hmac_key, message, hashlib.sha256)
69+
signature_b64 = signature.digest().encode('base64').rstrip('\n')
70+
sub_params['signature'] = signature_b64
71+
sub_params['key'] = self.api_key
72+
sub_params['passphrase'] = self.api_passphrase
73+
sub_params['timestamp'] = timestamp
6774

6875
self.ws = create_connection(self.url)
6976
self.ws.send(json.dumps(sub_params))

0 commit comments

Comments
 (0)