Skip to content
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

Updates to NASA Auth plugins and examples #1042

Merged
merged 1 commit into from
May 10, 2024

Conversation

reidsunderland
Copy link
Member

So far, my NASA authentication plugin has only been used in subscribe/sarra components to download files posted by polls. In those cases, the polls don't require any authentication.

In a case @andreleblanc11 is dealing with, the poll part also needs to authenticate.

I refactored the code to make it easier to call the authentication code from a poll. I also added an authenticate directory under flowcb for similar plugins.

The poll can authenticate by adding a small plugin that looks like this:

import sarracenia
import sarracenia.flowcb.authenticate.nasa_earthdata
import logging

logger = logging.getLogger(__name__)

class Nasa_omisips(sarracenia.flowcb.poll.Poll):
    def __init__(self, options):
        super().__init__(options, logger)
        self.auth = sarracenia.flowcb.authenticate.nasa_earthdata.Nasa_earthdata(options)
    
    def poll(self) -> list:
        # Inject bearer token in the credentials
        self.auth.add_token_for_url(self.o.pollUrl)

        # Run the normal HTTP poll, now that the bearer token has been
        # injected in the credentials DB it should work
        return super().poll()

Additionally, the poll_NASA_CMR plugin was broken. I think something changed recently to enforce having a pollUrl in a poll config file. When setting pollUrl in the config, I also had to start using the msg['post_baseUrl'] option added in #951.


I also updated related examples to match the changed plugin location/name.

Copy link

github-actions bot commented May 9, 2024

Test Results

209 tests   201 ✅  17s ⏱️
  1 suites    8 💤
  1 files      0 ❌

Results for commit 0b34d9d.

@reidsunderland reidsunderland merged commit ddb228c into development May 10, 2024
27 of 35 checks passed
@reidsunderland reidsunderland deleted the nasa_plugin_fix branch May 10, 2024 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants