question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Login isses due to Degiro's bot detection

See original GitHub issue

I have started experiencing a “Could not login” error, with the response from the server reading:

         <h2>Reference: CENSORED</h2>
         <h2>Remote IP: CENSORED</h2>
         <h2>Identifier: CENSORED=python_bot</h2>
         <h2>Date: 07/Dec/2022:11:42:43 +0100</h2>

Issue Analytics

  • State:open
  • Created 9 months ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
Jakub-CZcommented, Dec 21, 2022

I plan to maintain my fork for the foreseeable future. But if Degiro change their API so much that it’d take too much effort to adapt to the change, I’ll probably switch to another alternative at that point.

1reaction
petrkluscommented, Dec 20, 2022

@Jakub-CZ I managed to work around the issue by setting user-agent headers:

headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}

This is my complete __request method hotfix:

    @staticmethod
    def __request(url, cookie=None, payload=None, headers=None, data=None, post_params=None, request_type=__GET_REQUEST,
                  error_message='An error occurred.'):

        headers_def = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
        if headers:
            headers = dict(list(headers_def.items()) + list(headers.items()))
        else:
            headers = headers_def

        if request_type == DeGiro.__DELETE_REQUEST:
            response = requests.delete(url, json=payload, headers=headers)
        elif request_type == DeGiro.__GET_REQUEST and cookie:
            response = requests.get(url, cookies=cookie, headers=headers)
        elif request_type == DeGiro.__GET_REQUEST:
            response = requests.get(url, params=payload, headers=headers)
        elif request_type == DeGiro.__POST_REQUEST and headers and data:
            response = requests.post(url, headers=headers, params=payload, data=data)
        elif request_type == DeGiro.__POST_REQUEST and post_params:
            response = requests.post(url, params=post_params, json=payload, headers=headers)
        elif request_type == DeGiro.__POST_REQUEST:
            response = requests.post(url, json=payload, headers=headers)
        else:
            raise Exception(f'Unknown request type: {request_type}')

        if response.status_code == 200 or response.status_code == 201:
            try:
                return response.json()
            except:
                return "No data"
        else:
            raise Exception(f'{error_message} Response: {response.text}')
Read more comments on GitHub >

github_iconTop Results From Across the Web

Bot detection prevents login in some cases · Issue #604 - GitHub
After enabling bot detection in dev and testing the behavior, I am able to get into a scenario where I continually receive this...
Read more >
Getting "Error getting the bot detection challenge" when ...
We've implemented a custom html login view. Everything works fine, except that when the user logs in correctly and navigates back, ...
Read more >
How to detect & capture login bots
Detect attempted logins with usernames that don't exist​​ Identify a Bot when it tries to login with a non-existent username or an empty...
Read more >
github trading platform
Insight and information about trading platforms and APIs Cryptocurrency trading bot in javascript for Bitmex, Binance,. Microsoft acquired GitHub in 2018 ...
Read more >
Untitled
Xoom paypal login, Positive feedbacks for teachers, Delphi center of quincy, ... Browser detection javascript css, Marten cornelissen violin maker, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found