Почему я продолжаю получать ошибку 401 от coinbase API? - PullRequest
0 голосов
/ 03 мая 2020

Почему мне не удается получить доступ к монетной базе с помощью этой функции на основе API-R? Я хотел бы получить доступ к своей учетной записи.

show_an_user = function(endpoint = paste0("accounts"), method = "GET")
{                                                              
                               method = toupper(method)
                               timestamp1 <- as.character(as.integer(Sys.time()))

                               msg <- paste0(timestamp1, method, "/v2/", endpoint)
                               final <- digest::hmac(api_key, msg, algo = "sha256", raw = F, serialize = F)

                               baseUrl = paste0('https://api.coinbase.com/v2/', endpoint)

                               #Attach the required header to the function GET from httr
                               headers <- httr::add_headers(.headers = c("CB-ACCESS-KEY"=api_key,
                                                            "CB-ACCESS-SIGN"=final,
                                                            "CB-ACCESS-TIMESTAMP"=timestamp1,
                                                            "CB-VERSION" = "2020-04-26",
                                                            "Content-Type" = "application/json",
                                                            "Accept" = "application/json"))

                               #Send the request, attaching the header
                               response <- httr::GET(url = baseUrl, config = headers)
                               print(headers)
                               #Get the code if the request was successful
                               print(response)
                               print(httr::has_content(response))
                             }

Спасибо за вашу помощь!

...