I’ve read a lot on this forum as I’ve been getting this issue for most of the day. Here’s some code copy-pasted from someone else that they said worked, but it’s not working for me. Is someone else able to test it or can they see and problems with it? I’ve also tried this library and I’m getting the same issue.
public void Test()
{
string apiKey = "xxxxxxxxxxxxxx";
string apiSecret = "xxxxxxxxxxxxxx";
var baseUri = "https://coinbase.com";
var test_url = "/accounts";
var requestUri = "/api/v3/brokerage" + test_url;
var fullUri = baseUri + requestUri;
string contentBody = "";
var timeStamp = (int)TimeUtils.CurrentUnixTime;
var httpMethod = HttpMethod.Get;
string timestampStr = timeStamp.ToString("F0", CultureInfo.InvariantCulture);
string httpMethodStr = httpMethod.ToString().ToUpper();
var prehash = timestampStr + httpMethodStr + requestUri + contentBody;
// Convert the input string and key to byte arrays
byte[] prehashBytes = Encoding.UTF8.GetBytes(prehash);
byte[] keyBytes = Encoding.UTF8.GetBytes(apiSecret);
// Compute the SHA-256 hash of the input data using the key
HMACSHA256 hmac = new HMACSHA256(keyBytes);
byte[] hash2 = hmac.ComputeHash(prehashBytes);
// Convert the hash to a hexadecimal string
string signedSignature = BitConverter.ToString(hash2).Replace("-", "").ToLower();
var headers = new Dictionary<string, object>();
headers.Add("accept", "application/json");
headers.Add("CB-ACCESS-KEY", apiKey);
headers.Add("CB-ACCESS-SIGN", signedSignature);
headers.Add("CB-ACCESS-TIMESTAMP", timeStamp);
var response = HttpRequests.DoWebRequest(fullUri, HttpRequests.RequestMethod.GET, null, out _,
headers, null);
}