Powershell을 사용하여 Coinbase API를 통해 계정 잔액을 검색하고 싶습니다. Powershell을 사용한 Coinbase API 유효하지 않은 서명
나는 coinbase API 문서에서 다음 읽기를 구분하지만, 마지막 요청은 다음과 같은 오류가 발생합니다 :Invoke-RestMethod : {"errors":[{"id":"authentication_error","message":"invalid signature"}]}
여기 내 코드입니다. 무엇이 잘못 되었나요? 고맙습니다.
$accounts = 'https://api.coinbase.com/v2/accounts'
$time = 'https://api.coinbase.com/v2/time'
$epochtime = [string]((Invoke-WebRequest $time | ConvertFrom-Json).data).epoch
$method = 'GET'
$requestpath = '/v2/accounts'
$secret_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
$sign = $epochtime + $method + $requestpath
$hmacsha = New-Object System.Security.Cryptography.HMACSHA256
$hmacsha.key = [Convert]::FromBase64String($secret_key)
$signature = $hmacsha.ComputeHash([Text.Encoding]::ASCII.GetBytes($sign))
$signature = [Convert]::ToBase64String($signature)
$header = @{
"CB-ACCESS-SIGN"=$signature
"CB-ACCESS-TIMESTAMP"=$epochtime
"CB-VERSION" = '2017-08-07'
"CB-ACCESS-KEY"='xxxxxxxxxxxxxx'
}
Invoke-WebRequest $accounts -Headers $header
정말 대단하다 !!! ... Coinbase 문서화 API의 서명에 소문자 HEX를 놓쳤습니다. –
적어도 명시된 것 같지 않습니다. 필자는 먼 길은 소문자 버전을 만들어 내고 운 좋았습니다. –