diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c1f99b6..74983b6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - +## [0.9.1] - 2023-09-27 + +## Bugfix + +- Fix login issues on brazilian marketplace. + ## [0.9.0] - 2023-09-27 ## Bugfix diff --git a/src/audible/login.py b/src/audible/login.py index 90692da6..6491474c 100644 --- a/src/audible/login.py +++ b/src/audible/login.py @@ -487,12 +487,21 @@ def login( session.close() - if b"openid.oa2.authorization_code" not in login_resp.url.query: + url = None + if b"openid.oa2.authorization_code" in login_resp.url.query: + url = login_resp.url + elif len(login_resp.history) > 0: + for history in login_resp.history: + if b"openid.oa2.authorization_code" in history.url.query: + url = history.url + break + + if url is None: raise Exception("Login failed. Please check the log.") logger.debug("Login confirmed for %s", username) - authorization_code = extract_code_from_url(login_resp.url) + authorization_code = extract_code_from_url(url) return { "authorization_code": authorization_code,