question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: how to access credentials inside a node?

See original GitHub issue

What are you trying to do?

I am trying to perform ETL operations inside a node. To do this, I need access to database credentials.

Workaround

As a workaround, I can add sqlalchemy engine to DataCatalog in register_data_catalog hook dynamically, but I don’t think DataCatalog should be used in this way.

        catalog.add_feed_dict(
            {"mssql_engine": MemoryDataSet(self._mssql_engine, copy_mode='assign')}
        )

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
atgmellocommented, Jan 3, 2021

I have a similar usecase as the one mentioned by @bensdm. I also could not find a built-in way of getting this data from the credentials.yml. For now I simply wrap my credential loading in a node and pass the resulting dict as an input to wherever they’re needed. Something along the lines of:

# credentials.yml
# (...)
app:
    client_id: abc
    client_secret: xyz
# nodes.py
import yaml
# (...)
def get_app_credentials():
    with open("./conf/local/credentials.yml") as cred:
        cred_dict = yaml.safe_load(cred).get("app")
    return cred_dict

def authenticate_user(credentials):
  # (...)
  return something
# pipeline.py
# (...)
def create_pipeline(**kwargs):
    return Pipeline(
        [
            node(
                func=get_app_credentials,
                inputs=None,
                outputs="credentials"
            ),
            node(
                func=authenticate_user,
                inputs="credentials",
                outputs="something",
            ),
            # (...)
        ]
    )

Any thoughts or comments on whether this is an appropriate work-around or not are very much welcome!

5reactions
bensdmcommented, Oct 28, 2020

interested by the answer too, what if i need credentials to use let’s say a google API inside a node? how can I pass it as a param?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Question: how to access credentials inside a node? · Issue #575
I am trying to perform ETL operations inside a node. To do this, I need access to database credentials. Workaround. As a workaround,...
Read more >
Proper credentials for node & s3 - javascript - Stack Overflow
What are the best ways to set up credentials so that my node application can connect to S3 and download the specific objects...
Read more >
Get credentials information in expression - Questions - n8n
Hello, Is there a way to retrieve the credentials information (such as host, url and such) in an expression in the workflow ?...
Read more >
opConfig adding nodes and credentials
Select the menu "System", then "Edit Credential Sets". Credential sets can be shared by any number of nodes. Each credential set has to...
Read more >
Setting Credentials in Node.js - AWS SDK for JavaScript
Setting Credentials in Node.js · Loaded from AWS Identity and Access Management (IAM) roles for Amazon EC2 · Loaded from the shared credentials...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found