From 4806a2fc30db99edb37b4d1898f0891f71ab5599 Mon Sep 17 00:00:00 2001 From: Jerome Berthier Date: Thu, 2 Jan 2020 12:07:35 +0100 Subject: [PATCH] [cragr/api] handle new server error when SCA is required They change the json response, add a check to know whether we are going to get an SCA or not. --- modules/cragr/api/browser.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/cragr/api/browser.py b/modules/cragr/api/browser.py index 3d7f475099..82a215f574 100644 --- a/modules/cragr/api/browser.py +++ b/modules/cragr/api/browser.py @@ -143,12 +143,10 @@ def do_security_check(self): if any(value in message for value in technical_error_messages) or \ any(value in code for value in technical_error_codes): raise BrowserUnavailable(message) - elif error_type and 'UNAUTHORIZED_ERREUR_TYPE' in error_type: - # Usually appears when doing retries after a BrowserUnavailable - raise BrowserUnavailable() - # When a PSD2 SCA is required it also returns a 500, but info is under 'url' key - if exc.response.json().get('url') == 'dsp2/informations.html': + # When a PSD2 SCA is required it also returns a 500, hopefully we can detect it + if (exc_json.get('url') == 'dsp2/informations.html' or + exc_json.get('redirection', '').endswith('dsp2/informations.html')): return self.handle_sca() raise -- GitLab