-
Notifications
You must be signed in to change notification settings - Fork 81
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
New auth strategy: token-only #484
Comments
This would be awesome to have, instead of creating a requests query to the CMR API |
@battistowx @asteiker I feel this feature should really be prioritized before 1.0. I think we need a good way to keep track of these things, so I created a milestone and added this issue to it. I'm not attached to this solution, just feel we need something and want to get the discussion going :) ETAFTP! There was another issue I was also thinking should be completed before 1.0, and I forgot what it was. I'll find it at some point and add it to the milestone. |
First of all thanks for this library, it is very helpful for us! I have a question which is touching this issue. When we are doing |
Hm. When there are two tokens, the code is supposed to revoke and re-generate a token: earthaccess/earthaccess/auth.py Lines 165 to 180 in 7a79ea5
cc @betolink |
Token regeneration is not automatic, actually is not part of the top level API. It could be automatic if we encounter an expired token, as of now one can do this: import earthaccess
auth = earthaccess.login()
auth.refresh_tokens() |
Ah cool. Looks like we just need a bit of glue code to automate it :) Thanks, @betolink ! |
I had a look to support with a PR, but must admit that I struggle to understand what is going on. If I delete the tokens manually they are re-generated, no problem, however and not changing anything I sometimes end up having three working tokens (even though |
Would it be better to use find_or_create_token? We've used that here with no issues: https://github.com/nasa/gesdisc-tutorials/blob/main/notebooks/How_To_Download_a_Spatial_and_Variable_Subset_of_Level_1B_Data_Using_OPeNDAP.ipynb |
Yes, indeed, you beat me to the punch. And in case anybody is wondering, that endpoint is implemented to automatically deal with expired tokens, such that it always returns an active token (automatically generating one and returning it, if you only have expired tokens at the time of the request). |
Finally found time to check and that would work. Is it okay for you if I create a PR to change the handling of the token?
|
There should be no need to deal with a list of tokens. Our current token logic should be greatly simplified by making use of |
I don't believe that #782 directly addresses this particular issue, so I'm reopening this. |
Should we call this "token-only" strategy for clarity? |
Works for me. |
Related: #415, #479
Should we provide a method of persisting tokens as well? Should bearer token become the default strategy?
From Hackday meeting 2024-10-15: Luis and Matt agree it should be the default strategy.
The text was updated successfully, but these errors were encountered: