Title: Authentication failed with the Coinbase API Post by: w_t on March 31, 2018, 06:19:44 AM Goodmorning everyone,
I have an authentication problem with my account, through the Coinbase.com API. I tell you what's happening to me: - I opened a private account on Coinbase.com, - I created my API Keys, - I have enabled all the permissions to the keys, this means that I can perform all the operations possible with those APIs. - I read the developer's guide and I tried to write a small script to test the authentication, but nothing completely useless ..., I return this error: Code: string(237) "{"errors":[{"id":"authentication_error","message":"invalid signature"}],"warnings":[{"id":"missing_version","message":"Please supply API version (YYYY-MM-DD) as CB-VERSION header","url":"https://developers.coinbase.com/api#versioning"}]}" Since the examples are in other languages but I use PHP, I think I have made a mistake during the conversion of the script. This is the link of the official guide: https://developers.coinbase.com/docs/wallet/api-key-authentication This is my script: Code: <? Do you give me your opinion? I've been stuck here for 5 days and I can not understand what I'm missing. The assistance of Coinbase does not answer me and I have a project to deliver blocked. Thank you very much for any useful advice. Title: Re: Authentication failed with the Coinbase API Post by: starmyc on March 31, 2018, 08:06:47 AM Code: $message = $timestamp . 'GET' . 'https://www.mysite.it' . $body; I did only take a quick look, but this seems wrong to me. According to the documentation (https://developers.coinbase.com/docs/wallet/api-key-authentication), the "message" string must contain the path + params of the request url (eg: "/v2/exchange-rates?currency=USD"), not the complete url. Title: Re: Authentication failed with the Coinbase API Post by: w_t on March 31, 2018, 10:13:33 AM Code: $message = $timestamp . 'GET' . 'https://www.mysite.it' . $body; I did only take a quick look, but this seems wrong to me. According to the documentation (https://developers.coinbase.com/docs/wallet/api-key-authentication), the "message" string must contain the path + params (eg: "/v2/exchange-rates?currency=USD"), not the complete url. If your complete url is "http://www.mysite.it/", then the request path you need to use is only "/". Excuse me if I do not understand, my full URL what do you mean? The redirect address that I put during the registration of my account? Title: Re: Authentication failed with the Coinbase API Post by: starmyc on March 31, 2018, 04:31:08 PM I fixed my answer after testing. You can't use your website url in $message, you have to use the requestPath of the url you're querying. If you're querying "https://api.coinbase.com/v2/user", then you've to use "/v2/user" in $message to create the signature.
Please note it is recommended to use the CB-VERSION header as well. The following code works: Code: <?php |