hootnot / oanda-api-v20

OANDA REST-V20 API wrapper. Easy access to OANDA's REST v20 API with oandapyV20 package. Checkout the Jupyter notebooks!
MIT License
398 stars 107 forks source link

Client Access Not working for Instruments call or any data call #196

Closed kiann00 closed 1 year ago

kiann00 commented 1 year ago

Hi there,

I followed your example to try to extract the Instrument data to test my connection. It seems just the API token is not enough?

I am getting this error message : {"errorMessage":"Insufficient authorization to perform request."}

import oandapyV20
import oandapyV20.endpoints.instruments as instruments

client = oandapyV20.API(access_token= 'XXX')
params = {
  "count": 5,
  "granularity": "M5"
}

r = instruments.InstrumentsCandles(instrument="DE30_EUR", params= params)
client.request(r)
hootnot commented 1 year ago

Definitely a token issue. In case you use a live account you need to specify that when creating your client instance.

client = oandapyV20.API(access_token= 'XXX', environment="live")

Use r.response to get the data returned or use rv = client.request(r) and have the response value in rv

In case this was on a non-live account: drop the token and generate a new one