How do I form an OAuth1 request to Twitter from a workflow?

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

Nicholas Reilingh : Hi! Wondering what the “happy path” is for making an HTTP request with an OAuth 1.0a signature that includes an oauth_token. I’m trying to invoke this particular API endpoint: https://developer.twitter.com/en/docs/twitter-api/premium/account-activity-api/api-reference/aaa-premium#post-account-activity-all-env-name-webhooks

Nicholas Reilingh : I’ve gotten the “Twitter developer” app set up in pipedream, so I have access to both sets of tokens and secrets, and I started with axios and this interceptor package to provide the headers and request signing

Nicholas Reilingh : However, that package doesn’t support oauth tokens fully (there’s kind of some code present, but it isn’t implemented properly)

Nicholas Reilingh : So, I’m wondering if my best option is to fork that package and publish a fixed version, or if there’s another combination of request and auth tools that could help me

Dylan Sather (Pipedream) : Hi , just to confirm, it sounds like you’re using your own Twitter app and not the Pipedream OAuth app, correct?

If you’re using your own app, can you try using the twit package? They handle making the request on your behalf, given the Twitter keys / tokens. Take a look at this example workflow.

Nicholas Reilingh : Correct, in pipedream it’s the “Twitter Developer App”, so it’s configured for my own app in the twitter developer portal. That part is already working great for some other types of requests

Nicholas Reilingh : I had seen about the twit package, but it didn’t look like it supported the endpoint I was calling

Nicholas Reilingh : I’ll give it a closer look

Dylan Sather (Pipedream) : I believe twit supports the ability to call any endpoint via the get and post methods, e.g. check out https://github.com/ttezel/twit#tgetpath-params-callback

Dylan Sather (Pipedream) : but I haven’t used it extensively

Nicholas Reilingh : By the way, that example workflow you linked incorrectly destructures api_key_secret when it is supposed to be api_secret_key!

Dylan Sather (Pipedream) : fixed! Thanks

Dylan Sather (Pipedream) : Did that work for you once you made that change?

Nicholas Reilingh : No, I couldn’t figure out how to make Twit work for this endpoint – seemed to be doing too much magic that isn’t documented well enough for me to be sure it’s actually conforming to the API spec, so I was getting “could not authenticate you” errors. I found another package called twitter-lite that does seem to work, at least for that endpoint, but it fails for a different one!

Nicholas Reilingh : It’s really frustrating trying to use these 3rd-party API wrappers inside of pipedream when there’s no way to debug or inspect an outbound HTTP request

Nicholas Reilingh : at least with a generic request tool like Axios, it’s documented well enough that I can have a good level of confidence over what is happening

Nicholas Reilingh : with everything else I end up having to read through the source code on github :confused:

Dylan Sather (Pipedream) : Take a look at this workflow and let me know if that helps. Once you fill in your consumer keys / tokens, and add the appropriate data to the requestData object, this step should return a signed Authorization header that can be sent in OAuth 1 requests.

I’m interested in this, some days I’m looking for how to get another account authorization from twitter developer. I try workflow @dylburger but not sure how to implement it