-
-
Notifications
You must be signed in to change notification settings - Fork 34
Authentification no longer working #48
Comments
Thx for reporting this so quickly. If anyone is interested in having a look at f.ex. the N26 apk to provide information on how this could be done feel free to report in this thread. |
By the way PSD2 also means that banks (including N26, which seems to comply already) must provide an API for allowing access to account transactions, balance and payment initiation. However, if one want to access those API, they must be allowed to operate as a Payment Service Provider and having obtained certifications. A bit much for people that just want to check their account freely. Moreover, if somehow anyone could gain access to this PSD2 API, they lack a lot of information the N26 API provides, notably on the opposed account of transactions (MCC, name, city, or IBAN/BIC...). So if anyone (like me) was wondering the point of using the N26 API when there's a brand new one available, hopes this clears things up. |
Yeah they call it "open banking" yet you can't access the data as an individual and it is limited in the kind of data that is accessible 🤦♂️ I don't really know how to proceed with this. I think the only acceptable way to continue this lib would be to try to reverse engineer the two-step authentication currently used by N26 and implement it here too. Although inconvenient it should be possible to refresh the token indefinitely, just like with the current approach. For the CLI usage the token should probably be temporarily stored on the file system for repeated access. |
I've been examining it a bit and it looks like they're using graphql now for all API calls (in the browser) |
I did some digging in the browser as well. The good news is, that if you copy the request a browser makes verbatim into curl, the request works, so there is no fingerprinting or nonce or something else blocking it. |
The login flow of the N26 Android app on a non-paired device works as follows:
|
Would it be somehow possible to extract something from a paired phone using a man in the middle proxy that could be used with the CLI interface without the need for 2fa? |
@Sjord Thanks, this workflow is working in my personal hack - well described. Here's my entire flow:
|
One thing to figure out is how to get rid of the input() in there -basically if you do the final token POST before you have approved on the phone, it fails. I guess you could try in a loop, but it sounds bad. |
I guess there should be some kind of event that is been triggered on mobile approval. |
@julian-klode The website also has a considerable delay between approving the login in the app and continuing the website login. Is there any disadvantage to query in a loop other than that it feels bad? Any rate limit or something like that? Otherwise I would be fine with this solution - at least for now. |
@markusressel I don't know if it gets flagged as unusual or something and triggers security lockouts eventually. I'm a bit scared. |
Ok so I played around with your code @julian-klode and modified it to match the code style of python-n26. After a couple of (successful!) test runs I now get a I tried to do an automatic "retry" every 5 seconds for a maximum of 60 seconds in my last tests, which did not work as expected. Maybe this also contributes to the On the bright side the To keep the token around between processes I would like to store it somewhere on the system, but since this token data is very security relevant I am not sure where to do this. My initial thought was to simply store it in a file on the disk since the config file contained all relevant info anyway. But since access to the token data would also eliminate the mfa I am not so keen on actually publishing such a solution. Any input on that @femueller or maybe others that have solved a similar problem before? |
Just a little warning to anyone trying this out: Its 6 hours since I got the "30 minutes" timeout and I still cant login even via the official app when using the same Internet IP so it seems like they block based on the IP. When I use a 4G connection it works as normal. Im curious how long I have to wait before my home Internet IP works again... |
Thank you @Sjord, I am able to authenticate using the steps you describe. Has anyone been successful in doing a man in the middle proxy on a paired device, to see the 2fa steps? |
There is the man in the middle on a paired device, with password authentification :
Response :
Refresh Token
When I try to refresh my token with "grant_type=refresh_token" on
|
@bbastou in step 2, the mfaToken is the mfaToken from the step 1 response?¿ |
Yes, the first POST on |
Ok, im testing in postman and im getting this response,
|
@mvmisha Maybe it's a headers problem ? There is the postman collection I made for sms OTP auth : Don't forget to add your email/password in the env variable. |
Yep, headers it was The request at "Auth - Password - Valid OTP" will return the token to get other account information? Thanks! edit: Yeah, works fine getting transactions and account info.. BUT, the message that the client recives is in english.. not much of a problem, but if i login within the website the message is in spanish (in this case im in spain), any idea how to fix that? 🤔 |
You're welcome :) For french message, I add this header : |
I feel dumb for realising this so late, but my "longer than 30 minutes" IP block was caused by Home Assistant still using the N26 component and constantly trying to login using the old, now unsupported, way... So there seems to be no IP ban afaik. After disabling the n26 component in my Home Assistant instance and waiting a bit I was able to start testing again. @bbastou 30 day login would be really nice, but still there has to be a way to refresh the token. I guess they only refresh it after it has expired which it does after 900 (or 1800) seconds. Did you check what happens after this time? |
@markusressel My tests show that tokens last at least an hour, and that they definitely expire after some time. 15 hours and not minutes maybe? |
@nikolamilekic the toke has an |
@markusressel I have a small app that polls the API every hour. I only store the |
@nikolamilekic could you please elaborate:
|
The result of the 2FA authentication is an Then every hour I:
This has been working for 48 hours now so I guess the refresh tokens don't expire after 900 seconds. Let me know if you'd like to see the code I have so far (it's in F#). |
I think refresh tokens would still work after 90 days.. but I’m not sure about it Those 90 days are within PSD2 regulations I don’t know about N26, but other banks don’t requiere SCA if you already did it in that 90 day period, and it would be required also if you need to access account transactions that are older than 90 days.. but yeah the whole PSD2 thing is confusing and not all banks follow the rules |
@nikolamilekic the grand_type = refresh_token result on an error for me. I'd like to see the code you made to help me understand what is wrong with mine |
@bbastou It's all the changes I did for this. What's missing is code to get the initial token. I did that by hand using the steps described above. Let me know if there's anything I can clarify. |
Thanks a lot @nikolamilekic So the refresh_token didn't worked for me because I used the same api calls than the iOs application did. First call on If you make all your api call on |
Thx @bbastou, it is also a combination of using the |
I don't think you actually need the |
@julian-klode hmm I may have confused an error I got due to a failed refresh of a token I had not refreshed for a couple of hours. I assume your "last at least" refers to the access token that has been refreshed in the meantime? Or do you refer to the time the user has to refresh a token even after it has expired? |
@markusressel So, I stored the refresh token, waited 1h40m and then could get a new access token (and new refresh token) for it. It's not entirely clear how long the refresh token lasts, the last one from like 23:00 was expired at 10:00 this morning. My login workflow is to try to do a refresh, and if that fails, I login again. |
@julian-klode thats how its supposed to be done. Afaik you dont have to refresh the token if it has not yet expired, but you will not be able to refresh it if it has expired for too long (like you said and I experienced too). But for a continuous application like home assistant this should not matter, since it will make API calls at least every 30 minutes, so the refresh should always work. |
ack. In my case I have a script I run manually sometimes, hence it times out. But oh well, I could probably make it an hourly refresh Cron job. |
Bugfix/#48 new authentication flow
This is now part of the 2.0.0 release |
Thanks for all the hard work everyone – has anyone been able to get this working reliably without manual intervention? I've tried an hourly cron, but it seems like I eventually get: Refresh token not found! Any ideas? |
Same here, the token usually only works for 4 hours until I need to do the manual intervention again. This probably needs to be re-opened. |
I tested this in a terminal loop and can confirm that after 2 hours I had to reauthenticate. We will not reuse this issue for that Topic though and create a new one. |
From this day, 14th of September 2019, trying to log in with this client, whether from the module or with the CLI application, will result in a 403 error:
I believe this is due to enforcement of the Revised Directive on Payment Services (PSD2) enforcing "strong" authentication. In fact, from now on, connecting to the N26 web application requires you to validate the login attempt from the phone application.
So I guess the big question is, can this be worked around, or should we say goodbye to the N26 API (without an validation from the phone application, which defeats the purpose)?
The text was updated successfully, but these errors were encountered: