How can I pass a bearer token to other steps in a workflow and store it as an environment variable in Pipedream?

This topic was automatically generated from Slack. You can find the original thread here.

Newb Question - I would like to be able to pass a bearer token (that Pipedream fetches/stores) to other steps in a workflow and also locations/apps. I can see it in the workflow under the Results>Inputs>Detailed/code mode and can copy a path for the oauth_access_token (this.td_ameritrade.$auth.oauth_access_token) - but when I got to reference it in later code steps in the workflow - I cant see to retrieve it. Any clues what I am doing wrong. I would also like to know if its possible to store the bearer tokens that Pipedream manages and fetches as an “Environment Variable” - thanks

Hey Tom, can you tell me more about your use case for referencing the TDA Access Token? You can $.export() or return it in any step if you need to use it later in the workflow.

And I’m curious to hear more about the env var use case.

Hi Danny - For your question # 1 - I want to pass the token onto another app outside pipedream to create buy/sell orders. Using Pipedream for the authentication and other things that I need to do. Screenshot of the workflow is below. When I try to copy path and reference it in the next step

My question about storing the token as a ENV variable was in case it is not possible to pull it into to code steps using the “copy path” approach - maybe storing it as a variable would be easier and safer?

Oh okay, I understand. Just to confirm, the OAuth Access Token for any app is considered sensitive — that is all that’s required to make requests to their API on your behalf, so I just want to express caution when storing your token in a Google Sheet.

But if you want to do that, you totally can. In that TD Ameritrade step, you could do something like this:

return this.td_ameritrade.$auth.oauth_access_token

And that would allow you to reference it in later steps. Check out the docs for sharing data between steps here: Writing Node.js in Steps

thanks Danny - the sheet is only for quick test/proof of concept. I will not store it there. thanks!