nordigen / nordigen-python

Python library for the Nordigen API.
MIT License
56 stars 18 forks source link

Failing to fetch account id #7

Closed Gregster66 closed 1 year ago

Gregster66 commented 2 years ago

I have Nordigen setup with 1 account (bank : N26). When executing line 52: account_id = accounts["accounts"][0] ...I get the following error: account_id = accounts["accounts"][0] IndexError: list index out of range

I had to correct the code in that line to the following to work around my issue: account_id = accounts["id"]

victory-sokolov commented 2 years ago

Hello! Are you trying to run the main.py file?

account_id = accounts["accounts"] is returning list of available accounts, in main.py we are taking first available account_id just for example purposes. You cannot run main.py as a single executable file. You have to complete authorization with your back when you receive a link at Line 32 print(init.link) before going any further.

It is better to test it with Flask based example application that we are providing in the example directory

Gregster66 commented 2 years ago

I'm using the code that is posted in the documentation.

I am successfully completing the authorization and the accounts object is being populated, however in my case (when I have only 1 account) the accounts object is a dictionary and not an array, therefore it's failing when trying to get the first object of the array [0].

Gregster66 commented 2 years ago

no, disregard that last message. I actually had a look at the accounts["accounts"] and I have 0 objects there.

I do have a value in accounts["id"] so I'm assuming that the authorization is completed successfully but no accounts are listed. any reason why that might be the case?

victory-sokolov commented 2 years ago

Could you please try once again to connect with a bank account and then make sure you are passing correct requisition_id to the get_requisition_by_id, requisition_id is gathered together with auth link, so print whole result print(init) and copy it from there.

victory-sokolov commented 1 year ago

Closing for now. Let me know if you still have the same problem.

czephyr commented 1 year ago

Hi. I'm having the same behavior, everything seems to go smooth and I'm sure the requisition_id being passed is the correct one. Still no populated accounts object being returned. Some other things I might be missing?

{'id': 'xxx',
 'created': 'xxx',
 'redirect': 'https://nordigen.com',
 'status': 'CR',
 'institution_id': 'correct_institution',
 'agreement': 'xxxx',
 'reference': 'xxx',
 'accounts': [],
 'link': 'xxx',
 'ssn': None,
 'account_selection': False,
 'redirect_immediate': False}

This is being returned by the client.requisition.get_requisition_by_id function.

EDIT: Actually, trying out the Flask test app included in the repository I get an error screen from my bank website (Intesa Sanpaolo), which leads me to think this issue may be caused by an error on their side. What confuses me is that I can see correct transactions from the nordigen website.

EDIT SOLVED: I was missing this step during the creation of a requisition:

Follow the link to start the end-user authentication process with the financial institution. Save the requisition ID (id in the response). You will later need it to retrieve the list of end-user accounts.

The step is outlined in the quickstart guide.

The reason for which I could see the API output on the nordigen web app but not through the API is:

Note that accounts connected in this way are not associated with your company - they are linked directly to Nordigen. For this reason they will not be accessible to you via the API. If you want to experiment with your own account data via the API you should link it programatically.