I am new to APIs. Trying to send a get request for the following API (https://docs.deribit.com/#authentication-2).
The website gives an example authentication request, for which I should receive a JSON response.
curl -X GET "https://test.deribit.com/api/v2/public/auth?client_id=fo7WAPRm4P&client_secret=W0H6FJW4IRPZ1MOQ8FP6KMC5RZDUUKXS&grant_type=client_credentials"
-H "Content-Type: application/json"
I try the following in Python:
import requests
import json
import os
import hmac
from hashlib import sha256
api_name = 'foo'
client_id = 'bar'
client_secret = 'foo1'
ip_whitelist = 'bar2'
url = f'https://test.deribit.com/api/v2'
path_dir = os.getcwd().replace(' ','')
client_signature = hmac.new(bytes(client_secret, 'utf-8'), b'', sha256)
# params = {'client_id': client_id, 'client_secret': client_secret, 'client_signature': client_signature}
params = {'client_id': client_id, 'client_secret': client_secret, 'grant_type': 'client_credentials'}
r = requests.get(url, params=params)
I get Response[400]. If I print r.url, I am getting the same url as the example, with my credentials:
'https://test.deribit.com/api/v2/public/auth?client_id=foo&client_secret=bar&grant_type=client_credentials'
I then reread the documentation and paid attention to the grant_type
Which says that the parameter grant_type should have the client_signature, refresh_token and client_credentials. Can someone please explain this to me?
