Skip to content

Commit

Permalink
Merge pull request #31 from brightway-lca/account-error
Browse files Browse the repository at this point in the history
Notify users of account action required
  • Loading branch information
cmutel authored May 25, 2024
2 parents e71ac4d + 7d0d9f9 commit d517014
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ecoinvent_interface/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,19 @@ def _get_credentials(self, post_data: dict) -> None:
self.last_refresh = time()
self.access_token = tokens["access_token"]
self.refresh_token = tokens["refresh_token"]
elif any("error" in key.lower() for key in response.json()):
error_messages = [
msg for key, msg in response.json().items() if "error" in key.lower()
]
if "Account is not fully set up" in error_messages:
warnings.warn(
"Action required: please login to ecoquery to update your account."
)
else:
warnings.warn(
f"Error(s) found. Can't login correctly. Error log:\n{error_messages}"
)
response.raise_for_status()
else:
warnings.warn(
"Given credentials can't log in: error {}".format(response.status_code)
Expand Down

0 comments on commit d517014

Please sign in to comment.