Im trying to connecto to the Coinbase sandbox API. Ive done all the preliminary setup with the API keys and passphrase but I keep getting a 401 error. my code is below. Does anyone have an insights as to what I might be doing wrong here?
API_Secret = API_SECRET;
passphrase = PASSPHRASE;
API_KEY = API_KEY;
timestamp = num2str(round(posixtime(datetime())*1000));
message = [timestamp 'GET' '/accounts'];
signature = matlab.net.base64encode(HMAC(API_Secret, message,'SHA-256'));
url = 'https://api-public.sandbox.exchange.coinbase.com/accounts';
options = weboptions('ContentType', 'json', 'RequestMethod', 'get', ...
'HeaderFields', {'CB-ACCESS-KEY', API_KEY}, ...
'HeaderFields', {'CB-ACCESS-SIGN', signature}, ...
'HeaderFields', {'CB-ACCESS-TIMESTAMP', timestamp}, ...
'HeaderFields', {'CB-ACCESS-PASSPHRASE', passphrase});
response = webread(url, options);
data = jsondecode(response);