pd.inputs["slack"]["$auth"]["oauth_access_token"]
will contain your Slack account OAuth token.With that token, you can make authenticated API calls to Slack:from slack_sdkimport WebClientdef handler(pd:"pipedream"): # Your Slack OAuth token is available under pd.inputs token= pd.inputs["slack"]["$auth"]["oauth_access_token"] # Instantiate a new Slack client with your token client= WebClient(token=token) # Use the client to send messages to Slack channels response= client.chat_postMessage( channel='#general', text='Hello from Pipedream!' ) # Export the Slack response payload for use in future steps pd.export("response", response.data)
pd.inputs[appName]["$auth"]
WebClient
using the Slack OAuth access token:# Instantiate a new Slack client with your tokenclient= WebClient(token=token)
pd.inputs["slack"]
come from? Good question. It was generated when we connected Slack to our Python step.pd.inputs[appName]["$auth"]
object:from slack_sdkimport WebClientdef handler(pd:"pipedream"): token= pd.inputs["slack"]["$auth"]["oauth_access_token"] # Authentication details for all of your apps are accessible under the special pd.inputs["slack"] variable: console.log(pd.inputs["slack"]["$auth"])
pd.inputs["slack"]["$auth"]
contains named properties for each account you connect to the associated step. Here, we connected Slack, sothis.slack.$auth
contains the Slack auth info (theoauth_access_token
).The names of the properties for each connected account will differ with the account. Pipedream typically exposes OAuth access tokens asoauth_access_token
, and API keys under the propertyapi_key
. But if there’s a service-specific name for the tokens (for example, if the service calls itserver_token
), we prefer that name, instead.To list thepd.inputs["slack"]["$auth"]
properties available to you for a given app, just print the contents of the$auth
property:print(pd.inputs["slack"]["$auth"])# Replace "slack" with your app's name
Was this page helpful?