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

do not assume utf-8 for GET requests #370

Open
RokoTechnology opened this issue Jun 14, 2022 · 1 comment
Open

do not assume utf-8 for GET requests #370

RokoTechnology opened this issue Jun 14, 2022 · 1 comment

Comments

@RokoTechnology
Copy link

GET body is always returned in utf-8 as per

https://github.com/ciaranj/node-oauth/blob/master/lib/oauth.js#L404

this is causing issue while retrieving OAuth secured images, for example

https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/message-attachments/guides/retrieving-media

@RokoTechnology
Copy link
Author

RokoTechnology commented Jun 14, 2022

workaround would be to call _prepareParameters and then feed that as authorization header to your http client of choice

const headers = ctx.oa._prepareParameters(config.oauth.oauth_token, config.oauth.oauth_token_secret, 'GET', params.uri)

const strHeaders = 'OAuth ' + headers.map(h => h.map(hh => encodeURIComponent(hh)).join('="')).join('", ')

const result = await ctx.got(params.uri, { headers: {
  'Authorization': strHeaders
} })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant