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

allow log in with 2fa #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions degiroapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class DeGiro:
__LOGIN_URL = 'https://trader.degiro.nl/login/secure/login'
__LOGIN_TOTP_URL = 'https://trader.degiro.nl/login/secure/login/totp'
__CONFIG_URL = 'https://trader.degiro.nl/login/secure/config'

__LOGOUT_URL = 'https://trader.degiro.nl/trading/secure/logout'
Expand Down Expand Up @@ -34,15 +35,20 @@ class DeGiro:
client_info = any
confirmation_id = any

def login(self, username, password):
def login(self, username, password, totp=None):
login_payload = {
'username': username,
'password': password,
'isPassCodeReset': False,
'isRedirectToMobile': False
}
login_response = self.__request(DeGiro.__LOGIN_URL, None, login_payload, request_type=DeGiro.__POST_REQUEST,
error_message='Could not login.')
if totp is not None:
login_payload["oneTimePassword"] = totp
login_response = self.__request(DeGiro.__LOGIN_TOTP_URL, None, login_payload, request_type=DeGiro.__POST_REQUEST,
error_message='Could not login.')
else:
login_response = self.__request(DeGiro.__LOGIN_URL, None, login_payload, request_type=DeGiro.__POST_REQUEST,
error_message='Could not login.')
self.session_id = login_response['sessionId']
client_info_payload = {'sessionId': self.session_id}
client_info_response = self.__request(DeGiro.__CLIENT_INFO_URL, None, client_info_payload,
Expand Down