Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github.request() should respect custom headers like Accept, Authorization etc. #272

Open
tlenex opened this issue Jul 1, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@tlenex
Copy link

tlenex commented Jul 1, 2022

Is your feature request related to a problem? Please describe.
I'd like to make custom, external request with custom headers for fetching data using github.request() in my github-script.
However, the method is ignoring custom HTTP headers provided in it's options like Accept and Authorization - I didn't check any others User-agent might also be the case.

Describe the solution you'd like
Script like this:

github.request('POST https://example.com', {
  // I want headers to be like this:
  headers: {
    authorization: 'Bearer xxx',
    accept: 'application/vnd.heroku+json; version=3',
    'content-type': 'application/json'
  }
});

Could respect given headers in the request options.
It would be a really nice way of fetching data in github-script without usage of additional steps/libs/dependencies.

Describe alternatives you've considered
Using bash step with curl or exec.exec('curl'); in github-script step, but both feel clunky in this case. Installing node deps like node-fetch seems like a waste of time and resources, especially when github.request() is using exactly node-fetch under the hood, but we just can't access it.

Additional context
https://stackoverflow.com/questions/72815672/cant-override-some-http-headers-with-github-request-in-actions-github-script

@tlenex tlenex changed the title github.request() should respect custom headers like Accept, Authorization, Content-type etc. github.request() should respect custom headers like Accept, Authorization etc. Jul 1, 2022
@joshmgross joshmgross added the enhancement New feature or request label Jan 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants