-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use new IIASA-manager API with token refresh #684
Use new IIASA-manager API with token refresh #684
Conversation
The equivalent to the anonymous login would be logging in as the "guest" user. |
Codecov Report
@@ Coverage Diff @@
## main #684 +/- ##
=======================================
- Coverage 94.7% 94.7% -0.1%
=======================================
Files 59 59
Lines 5807 5836 +29
=======================================
+ Hits 5504 5529 +25
- Misses 303 307 +4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Ok, not sure if the "guest" user should have a password... Let's discuss next week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm from an integration standpoint, I made a few notes.
def obtain_jwt(self): | ||
r = self.client.post("/v1/token/obtain/", json=self.creds) | ||
if r.status_code == 401: | ||
raise ValueError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use self.auth_url here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a (non-expert) user reads the error message and tries to put the auth-url into his/her browser, this returns an unhelpful "Not Found" page - so I would rather use a url that users can "use".
pyam/iiasa.py
Outdated
r = requests.get(url, headers=self._headers) | ||
# TODO: application-list will be reimplemented in conjunction with ixmp-server | ||
url = "/".join([self._auth_url, "legacy", "applications"]) | ||
r = requests.get(url, headers=self.auth()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use httpx here as well. You can pass the auth object when instantiating the client and it will be called for every request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, implemented!
Please confirm that this PR has done the following:
Documentation AddedName of contributors Added to AUTHORS.rstDescription of PR
This PR refactors the IIASA-manager-API authentication to the new (short-lived) token, including automated refresh. The PR also stricter behavior when reading a config file fails, and adds explicit test if arguments are missing from the credentials.
We decided to leave the current legacy-implementation for the anonymous login and application-list, because these features will change with the new ixmp package.