goanda
goanda copied to clipboard
Authorization issue
Hi, after I changed the code to:
package main
import (
"log"
"os"
"github.com/awoldes/goanda"
"github.com/davecgh/go-spew/spew"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
key := os.Getenv("OANDA_API_KEY")
accountID := os.Getenv("OANDA_ACCOUNT_ID")
oanda := goanda.NewConnection(accountID, key, false)
history := oanda.GetCandles("EUR_USD", "10", "1M")
spew.Dump(history)
}
I am getting the following error:
2018/10/23 13:46:22 /root/go_projects/src/github.com/awoldes/goanda/utils.go:22:
OANDA API Error: {"errorMessage":"Insufficient authorization to perform request."}
On route: /instruments/EUR_USD/candles?count=10&granularity=1M
Account is good, I have tried with curl and it works.
I didn't have any auth issues when trying just now, can you add print statements locally to make sure your api key and account id are getting set correctly? If you're calling godotenv.Load() you don't need to load them again with os.Getenv.
Also, 1M doesn't appear to be a valid granularity per the link below.
http://developer.oanda.com/rest-live-v20/instrument-df/#CandlestickGranularity