Skip to content

Encode spaces in parameter values for oauth-1.0a#93

Open
edsu wants to merge 3 commits into
HunterLarco:masterfrom
edsu:master
Open

Encode spaces in parameter values for oauth-1.0a#93
edsu wants to merge 3 commits into
HunterLarco:masterfrom
edsu:master

Conversation

@edsu

@edsu edsu commented Sep 30, 2021

Copy link
Copy Markdown

This commit fixes #90 by making sure that spaces in URLs are encoded using %20 instead +. While technically correct the underlying oauth-1.0a library will encode a + as %2B when signing, which causes an 401 Authentication error, because the URL that was signed was not the URL that was fetched.

The fix isn't particularly satisfying, but it does pass the tests except for should stream data without any rules which was already failing.

This is a simple test of tweets/search/recent with access keys along the
lines of what is done for consumer keys. It currently fails with a 401
exception. See HunterLarco#90 for details.
This commit fixes HunterLarco#90 by making sure that spaces in URLs are encoded
using %20 instead +. While technically correct the underlying oauth-1.0a
library will encode a + as %2B when signing, which causes an 401
Authentication error, because the URL that was signed was not the URL
that was fetched.

The fix isn't particulary satisfying, but it does pass the tests except
for `should stream data without any rules` which was already failing.
This is a build so I can npm install from GitHub until this HunterLarco#90 is fixed.
@rn4n

rn4n commented Sep 30, 2021

Copy link
Copy Markdown

Thanks! 😄 Waiting for this fix.

@d3rf

d3rf commented Oct 17, 2021

Copy link
Copy Markdown

I just wanna get twitter username in streaming, someone has a code that´s show how get that?

const endpointParameters = {
'tweet.fields': [ 'author_id', 'id', 'text' ],
'expansions': [ 'author_id', 'referenced_tweets.id' ],
'user.fields':['username','name'],
'media.fields': [ 'url' ]
}
cfc.listenForever(
() => tweetAPI.stream('tweets/search/stream',endpointParameters),
(data) => client.sendMessage(....@g.us',${data.text} )
);

So in listenForever the data dont shows username

@hubgit

hubgit commented Jan 17, 2022

Copy link
Copy Markdown

Needed this - thanks @edsu!

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

Successfully merging this pull request may close these issues.

Unauthorized(401) when using tweets/search/recent

4 participants