lolokraus / DegiroAPI

An unofficial API for the trading platform Degiro, with the ability to get real time data and historical data
MIT License
215 stars 86 forks source link

Exception: Could not login. #56

Closed schlummer13 closed 1 year ago

schlummer13 commented 1 year ago

Hi folks!

The Login doesn't work, I get the Exception Could not login and a HTML Response.

Can you fix it?

schlummer13 commented 1 year ago

Nevermind! A header with a user agent must be sent with the request. Then Degiro will no longer have a problem with it!

Jakub-CZ commented 1 year ago

@schlummer13 Thanks for letting us know.

One of these days, I'll give up on this library, and I'll switch to one of the actively maintained alternatives. However, today is not the day.

For anyone interested, my fork includes the fix for this issue: https://github.com/Jakub-CZ/DegiroAPI/commit/01d3a80625c989c804efd73ec28fa5ac61c2dc39. It can be installed directly like this:

pip install -U git+https://github.com/Jakub-CZ/DegiroAPI.git
JMKwins commented 1 year ago

Thanks @Jakub-CZ Would be super useful to merge it in the master if possible.

Jakub-CZ commented 1 year ago

@JMKwins The owner of this repo has been inactive for over a year. Nobody else can do anything in here. Even perfectly functional Pull Requests are ignored.

Somebody forked this repo and went on releasing the package under a different name to PyPI, but even that died eventually.

For a good support, you may want to consider an alternative. degiro-connector seems to be a much better, higher quality project, and it's also in Python.

amoratoc commented 1 year ago

@schlummer13 How do you add a header with user agent in the request? thanks a lot!

Jakub-CZ commented 1 year ago

@amoratoc Dude, it's right there in my commit that I linked above: https://github.com/Jakub-CZ/DegiroAPI/commit/01d3a80625c989c804efd73ec28fa5ac61c2dc39

aaronwtr commented 1 year ago

@Jakub-CZ Thanks for the fix! Worked for me. @schlummer13 out of curiosity, might I ask how you figured out the problem was with the headers? The error message did not seem to suggest this to me in the slightest. Thanks again!

schlummer13 commented 1 year ago

@aaronwtr Some websites block the standard User Agent header of requests. Since I saw that no header is used there, I tried it. It wasn't the error, it was the server's response. This is an HTML titled "Blocked" that brought me to it.

brogel commented 1 year ago

I installed this new version 0.9.7 , with the header info. Now i get following error: Header part (1234567) from {'intAccount': 1234567} must be of type str or bytes, not <class 'int'>

Anything I'm missing here again?

Jakub-CZ commented 1 year ago

@brogel It would be easier to find what's wrong if you'd post the whole error. On the other hand, the whole internet doesn't need to know your account number.

Anyway, I found the error. The functions buyorder and sellorder were broken for quite some time now.

I fixed them in my master branch again (https://github.com/Jakub-CZ/DegiroAPI/commit/93b699efc525c7b24646527c1a90767ffad14a66). Install from the specific commit...

pip install -U git+https://github.com/Jakub-CZ/DegiroAPI.git@93b699efc525c7b24646527c1a90767ffad14a66

... or simply from my master branch (which is where I'll continue fixing things while maintaining backwards compatibility):

pip install -U git+https://github.com/Jakub-CZ/DegiroAPI.git