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

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

edsu
Copy link

@edsu edsu commented Sep 30, 2021

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
Copy link

rn4n commented Sep 30, 2021

Thanks! 😄 Waiting for this fix.

@d3rf
Copy link

d3rf commented Oct 17, 2021

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
Copy link

hubgit commented Jan 17, 2022

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