Skip to content
This repository was archived by the owner on Oct 29, 2023. It is now read-only.

Bugfix/#48 new authentication flow#49

Merged
markusressel merged 9 commits intomasterfrom
bugfix/#48_new_authentication_flow
Sep 24, 2019
Merged

Bugfix/#48 new authentication flow#49
markusressel merged 9 commits intomasterfrom
bugfix/#48_new_authentication_flow

Conversation

@markusressel
Copy link
Copy Markdown
Collaborator

fixes #48

This PR implements the new 2FA required by N26.

To prevent having to reapprove every single CLI command a new config option has been added to specify a file path where access token data can be saved on the file system. This config option is optional though and by default None. If this config option is not set the token data will only be stored in memory and never written to disk.

After issuing a command without a previous authentication attempt the user has 60 seconds to approve the login using his paired phone and N26 app. To implement a simple "retry" logic I added the tenacity dependency.

slight refactoring
added tenacity dependency for "retry" behaviour
added global BASE_URL
use global base url to refresh token
refactoring
read token_data from memory or file system depending on the current config
added Authentication info to README
test fix
@markusressel markusressel self-assigned this Sep 23, 2019
Comment thread n26/api.py
Comment thread n26/api.py
@markusressel
Copy link
Copy Markdown
Collaborator Author

Although the mixed use of the .de and .global domains is probably irrelevant I dont want to waste another day to thoroughly test this so I will just leave it in the current state. I will open an issue for it and we can clean this up at a later stage.

@markusressel markusressel merged commit c64273a into master Sep 24, 2019
@markusressel markusressel deleted the bugfix/#48_new_authentication_flow branch September 24, 2019 20:32
@SoftCreatR
Copy link
Copy Markdown

Is there a way to refresh the token after expiry (899 seconds) using the refresh_token?

@markusressel
Copy link
Copy Markdown
Collaborator Author

Yes it is. From my understanding thats the way it is supposed to be and how it is implemented in this library. We dont know exactly how long it is possible though since this is not specified in the jwt specification and is hard to test as well.

@SoftCreatR
Copy link
Copy Markdown

Okay then. Seems, that the token doesn't hold longer than a day (i've tested your library yesterday and today, i had to re-log-in).

@markusressel
Copy link
Copy Markdown
Collaborator Author

If you want to keep the login I recommend you execute some call at least every 30 minutes or so. This should keep the token valid forever.

@SoftCreatR
Copy link
Copy Markdown

Makes absolute sense. Ty for the hint.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Authentification no longer working

2 participants