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

OAuth Refusing Connection - R - Works with twitteR package, but not with httr? #441

Closed
Jibril2 opened this issue May 14, 2017 · 4 comments
Closed
Labels
oauth 🏓 reprex needs a minimal reproducible example

Comments

@Jibril2
Copy link

Jibril2 commented May 14, 2017

The code I am using is as follows...

myKey = "xxxxxxxxxxxx"
mySecret = "xxxxxxxxxxxxx"
accessToken = "xxxxxxxxxxxx-xxxxxxxxxxxx"
accessSecret = "xxxxxxxxxxxx"


myapp = oauth_app("twitter", key=myKey, secret=mySecret)
sig = sign_oauth1.0(myapp, token=accessToken, token_secret=accessSecret )
url = paste( "https://api.twitter.com/1.1/search/tweets.json?", "q=13+Reasons+Why", sep="")
GET(url, sig)

That always gives me a 401 error authentication failed.

Meanwhile, using library(twitteR)

setup_twitter_oauth( consumer_key=myKey, consumer_secret=mySecret, access_token=accessToken, access_secret = accessSecret)
Accepts the OAuth.

@hadley hadley added oauth 🏓 reprex needs a minimal reproducible example labels Jul 24, 2017
@hadley
Copy link
Member

hadley commented Jul 24, 2017

Can you please provide a minimal reprex (reproducible example)? The goal of a reprex is to make it as easy as possible for me to recreate your problem so that I can fix it: please help me help you!

If you've never heard of a reprex before, start by reading "What is a reprex", and follow the advice further down the page. Please make sure your reprex is created with the reprex package as it gives nicely formatted output and avoids a number of common pitfalls.

@yutannihilation
Copy link
Contributor

I believe #424 will fix this issue.

@Jibril2 If you use "q=13ReasonsWhy" instead of "q=13+Reasons+Why", the status code will be 200, right? I think this is because oauth_encode() fails to handle +.

@yutannihilation
Copy link
Contributor

yutannihilation commented Jul 24, 2017

I believe #424 will fix this issue.

Sorry, this was my misunderstanding...

The issue seems involved with the order of parsing the URL and generating the signature, which may not be fixed easily.

# 401
GET(url, sig)

# OK
GET(parse_url(url), sig)
# OK
GET("https://api.twitter.com/1.1/search/tweets.json",
    query = list(q = "13+Reasons+Why"), sig)

Anyway, I will wait for the reprex :)

@hadley
Copy link
Member

hadley commented Aug 1, 2017

I've closed this issue due to lack of requested reprex. If you still care about this bug, please open a new issue with a reprex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
oauth 🏓 reprex needs a minimal reproducible example
Projects
None yet
Development

No branches or pull requests

3 participants