Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'x-security-token' #1

Open
femtotrader opened this issue Nov 21, 2014 · 0 comments
Open

KeyError: 'x-security-token' #1

femtotrader opened this issue Nov 21, 2014 · 0 comments

Comments

@femtotrader
Copy link
Contributor

Hello,

I'm trying for the first time you Python IG Market API code with a demo account but it raises

{"accountType":"CFD","accountInfo":{"balance":30000.0,"deposit":0.0,"profitLoss":0.0,"available":30000.0},"currencyIsoCode":"EUR","currencySymbol":"E","currentAccountId":"HIDDEN_DATA","lightstreamerEndpoint":"https://demo-apd.marketdatasystems.com","accounts":[{"accountId":"HIDDEN_DATA","accountName":"Demo-CFD","preferred":true,"accountType":"CFD"}],"clientId":"HIDDEN_DATA","timezoneOffset":1,"hasActiveDemoAccounts":true,"hasActiveLiveAccounts":true,"trailingStopsEnabled":false,"reroutingEnvironment":null,"dealingEnabled":true}
Traceback (most recent call last):
  File "main.py", line 10, in <module>
    account_info = ig_service.switch_account('HIDDEN_DATA', False)
  File "/Users/femto/fx/femtoprojects/python/ig_markets/ig-markets-rest-api-python-library/ig_service.py", line 371, in switch_account
    self.set_headers(response.headers, False)
  File "/Users/femto/fx/femtoprojects/python/ig_markets/ig-markets-rest-api-python-library/ig_service.py", line 421, in set_headers
    self.SECURITY_TOKEN = response_headers['X-SECURITY-TOKEN']
  File "/Users/femto/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/requests/structures.py", line 54, in __getitem__
    return self._store[key.lower()][1]
KeyError: 'x-security-token'

I did this

    try:
        self.SECURITY_TOKEN = response_headers['X-SECURITY-TOKEN']
    except:
        self.SECURITY_TOKEN = None

to fix it

But I don't know if that's risky.

Kind regards

Femto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant