-
Notifications
You must be signed in to change notification settings - Fork 42
Description
Overview
I wanted to create a repo that would use the flat action to store some data from the Twitter API. The problem is the Twitter API requires authorization in order to get any data. With the current version of the flat action (v2.0.2) there's no way to do this.
I created a fork of this repo that can do just that and published it to the marketplace. I wanted to submit a PR but wasn't sure if y'all would actually want to add it the way I did it so I figured I'd share what I did and leave it up to y'all.
Below is an explanation of my solution, and here is a link to my repo where I use the action I created:
My Solution
What I did to enable authorization was add a field to the actions with field called Authorization. The value of this field is then passed in as an Authorization header.
The following code snippets are the changes I made to the existing code, there's only three files I changed (aside from the README):
const response = await axios.get(config.http_url, {
method: 'get',
responseType: 'stream',
headers: {
Authorization: config.Authorization,
},
})const HTTPConfigSchema = z
.object({
http_url: z.string(),
Authorization: z.string().optional(),
})
.merge(CommonConfigSchema)
// ...
const keys = [
'downloaded_filename',
'http_url',
'Authorization',
'sql_connstring',
'sql_queryfile',
'postprocess',
]Authorization:
description: 'A string to send as a header for authorizing API requests.'
required: falseLinks
Current Flat Action Release
My Fork
My Published Action
My Example Usage