Create Coinbase Order - 401 unauthorized

I have found a number of posts, but none seem to help…
I have tried php, curl and javascript. I can do any GET, but not a single post.
Does anyone have an example of curl or javascript actually working - including the authorization?
here is the latest go around using javascript
FYI - the error is always (on post) “ERR_ABORTED 401 (Unauthorized)”

var raw = JSON.stringify({
“client_order_id”: “6556d745-7c3a-4a1e-8f41-623b51beb269”,
“product_id”: “BTC-USD”,
“side”: “BUY”,
“order_configuration”: {
“limit_limit_gtc”: {
“base_size”: “0.01”,
“limit_price”: “15000.0”,
“post_only”: false
}
}
} );

var myHeaders = new Headers();
myHeaders.append(“Content-Type”, “application/json”);
myHeaders.append(“CB-ACCESS-KEY”, “XXXXXX”);
myHeaders.append(“CB-ACCESS-SIGN”, “04e63ecba68bd748b19a5a18c79847bdeacXXXXXXXXXXX”);
myHeaders.append(“CB-ACCESS-TIMESTAMP”, “1713147220”);

var requestOptions = {
method: ‘POST’,
mode: “no-cors”,
headers: myHeaders,
body: raw,
redirect: ‘follow’
};
fetch(“https://api.coinbase.com/api/v3/brokerage/orders”, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log(‘error’, error));

I have the following permissions:
wallet:accounts:create wallet:accounts:delete wallet:accounts:read wallet:accounts:update wallet:addresses:create wallet:addresses:read wallet:buys:create wallet:buys:read wallet:checkouts:create wallet:checkouts:read wallet:contacts:read wallet:deposits:create wallet:deposits:read wallet:notifications:read wallet:orders:create wallet:orders:read wallet:orders:refund wallet:payment-methods:delete wallet:payment-methods:limits wallet:payment-methods:read wallet:sells:create wallet:sells:read wallet:supported-assets:read wallet:trades:create wallet:trades:read wallet:transactions:read wallet:transactions:request wallet:transactions:send wallet:transactions:transfer wallet:user:email wallet:user:read wallet:user:update wallet:withdrawals:create wallet:withdrawals:read

Are you including body in signature generation?

Yes,
In the CB-ACCESS-SIGN

timeseconds + ‘POST/api/v3/brokerage/orders’ + raw

This is how it looks:
1713188012POST/api/v3/brokerage/orders{“client_order_id”:“6556d745-7c3a-4a1e-8f41-623b51beb269”,“product_id”:“BTC-USD”,“side”:“BUY”,“order_configuration”:{“limit_limit_gtc”:{“base_size”:“0.01”,“limit_price”:“15000.0”,“post_only”:false}}}

Hi @wmgilligan

Based on the provided JavaScript code, it seems that you are attempting to make a POST request to the Coinbase brokerage orders API. However, you are receiving a “401 Unauthorized” error. Here are a few suggestions to help resolve the issue:

  1. Double-check your API credentials: Ensure that the values for “CB-ACCESS-KEY”, “CB-ACCESS-SIGN”, and “CB-ACCESS-TIMESTAMP” are correct. These credentials are used for authentication, and an incorrect value can result in an unauthorized error.
  2. Verify the request format: Make sure that the request payload is in the correct format and matches the API’s requirements. Check the API documentation for the expected payload structure and ensure that your request aligns with it.
  3. Check for rate limiting: Coinbase API has rate limits in place. If you have exceeded the rate limit for the specific endpoint, you may receive an unauthorized error. Refer to the Coinbase API documentation to understand the rate limits and ensure that you are within the allowed limits.
  4. Test with a different API endpoint: If the issue persists, try making a POST request to a different API endpoint to see if you encounter the same error. This can help determine if the issue is specific to the brokerage orders API or if it’s a more general problem.