Hey Everyone, Building a custom extractor, works ...
# plugins-general
d
Hey Everyone, Building a custom extractor, works perfectly. However, it's using
api_key
as auth method. I want the authenticator to pull the value for the
api_key
from the
.env
file as it's currently stored as value in the config block in
meltano.yml
. I've searched the docs but I'm at a loss as to how to do this for a custom plugin, without importing
dotenv
. I've tried following examples from existing taps which appear to pull values from
.env
files using
self.config
If I put the key in the
.env
file I get an error stating that
auth_token
is a required field. Indicating that Meltano is looking through the config block but not looking through the
.env
file.
Copy code
@property
def authenticator(self) -> APIKeyAuthenticator:
"""Return a new authenticator object.

    Returns:
      An authenticator instance.
    """
return APIKeyAuthenticator.create_for_stream(
      self,
      key=self.config["key_name"],
      value=self.config["auth_token"],
      location="header",
    )
āœ… 1
r
What command are you running to test your plugin? You have to invoke it through Meltano to leverage config lookup from shell environment or
.env
(as well as other sources, like
meltano.yml
):
Copy code
meltano invoke my-custom-extractor
or pass the value
ENV
for the
--config
option if invoking the plugin directly
Copy code
poetry run my-custom-extractor --config ENV
If you already have config in the
meltano.yml
that that plugin is picking up, I'm assuming you are already invoking it through Meltano to test, in which case a couple of things to check: •
.env
should be at the root of the Meltano project (same level as
meltano.yml
) • Environment variable name should be set to
<PLUGIN_NAME>_<SETTING_NAME>
(i.e.
TAP_CUSTOM_EXTRACTOR_AUTH_TOKEN
): https://docs.meltano.com/guide/configuration/#configuring-settings
d
.env
wasn't in root dir of project šŸ¤¦ā€ā™‚ļø
šŸ˜… 2
Thanks Reuben!
r
Haha, no problem šŸ˜„