TwitteR setup_twitter_oauth() gives an error - r

I am using twitteR package for the first time.
The setup_twitter_oauth function gives me an error:
[1] "Using browser based authentication"
Error in curl::curl_fetch_memory(url, handle = handle) :
Couldn't connect to server
or
[1] "Using browser based authentication" Error in
init_oauth1.0(self$endpoint, self$app, permission =
self$params$permission, : Bad Request (HTTP 400).
My code:
library(dplyr)
library(purrr)
library(twitteR)
setup_twitter_oauth(getOption("twitter_consumer_key"),
getOption("twitter_consumer_secret"),
getOption("twitter_access_token"),
getOption("twitter_access_token_secret"))
I am using Rstudio and Windows 7 with a proxy.

I believe the problem is that you're literally passing in those strings as arguments to setup_twitter_oath. They should be replaced by access tokens that Twitter gives you when you register your app.
You can assign the actual credentials to objects like
my_key, my_secret, my_access_token, my_access_secret
and then connect like this:
setup_twitter_oauth(my_key, my_secret, my_access_token, my_access_secret)
I noticed that if I try to connect with no credential or fake credentials that I get the same error you were experiencing from setup_twitter_oauth.
Make sure not to quote those objects or they're considered literal character strings.

Related

httr::oauth1.0_token returns HTTP 403

I tried to use httr::oauth1.0_token to authenticate against Twitter, but I got an error:
library(httr)
oauth1.0_token(oauth_endpoints("twitter"),
oauth_app("tw", key = Sys.getenv("Twitter_API"),
secret = Sys.getenv("Twitter_Key")))
# Error in init_oauth1.0(self$endpoint, self$app, permission = self$params$permission, :
# Forbidden (HTTP 403).
As I am new to OAuth authentication, I started reading the Twitter Docs and built the authentication dance from scratch.
After a lot of trial and error, I was eventually successful, so I can rule out that something on the twitter app setting end is wrong (that is the endpoint is set up correctly and especially the callback URL is defined properly, furthermore key and secret are the correct ones).
Before filing a bug report, I wanted to double check that I am using oauth1.0_token correctly. Thus, is this a bug or am I the bug?

ZendeskR Producing the following error when trying to connect to api

I am fairly new to using APIs and trying to use the zendesk API now through R using the ZendeskR package. I belive I have connected to it however I keep getting the following error whenever I try to query it.
Here is my code:
library(zendeskR)
library(rjson)
zendesk(username, password, url)
ticket <- getTicket('20150')
The username, password and url are all variables that I have assigned the correct values.
The following error that I get when I run it is this:
Error in function (type, msg, asError = TRUE) :
error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
Please help as I am unsure on what this error means or what I am doing wrong.
Thanks.
TLS v1.1 is no longer accepted by Zendesk, please use TLS v1.2.

OAUTH authentication with bigQueryR results in Unauthorized (HTTP 401) error

I try to use bigQueryR with OAUTH authentication (I have my reasons not to use service key authentication).
As the documentation suggests I did the following and received an error:
> library(bigQueryR)
> bqr_auth()
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.
Error in oauth2.0_access_token(endpoint, app, code = code, user_params = user_params, :
Unauthorized (HTTP 401). Failed to get an access token.
In addition: Warning message:
In googleAuthR::gar_auto_auth(required_scopes, new_user = new_user, :
travis_environment_var argument is now unsupported and does nothing
In this project I already used OAUTH successfully with bigRQuery (note, not bigQueryR), thus I already had a .httr-oauth file in my working directory.
I also tried to remove this file and then authenticate again. Same error. I also tried bqr_auth(new_user = TRUE) without success. With googleAuthR::gar_auth(new_user = TRUE) I get the same error as well.
I'd like to know how to resolve this issue.
Found the answer by accident soon after posting the question. This is due to a bug in bigQueryR: https://github.com/cloudyr/bigQueryR/issues/45
The creator of the package suggests to use the service key authentication method until a fix is in place.
EDIT - creator of the package closed this issue. Hopefully solved now.

Error in callAPI(query, token)

I had tried to access my FB token using the preliminary code shown by pablo over here :
https://github.com/pablobarbera/Rfacebook
However I get the following error message :
Error in callAPI(query, token) :
An active access token must be used to query information about the current user.
I used this code:
fb_oauth <- fbOAuth(app_id="14025", app_secret="5fdb6ef5776",extended_permissions = TRUE)
save(fb_oauth, file="fb_oauth")
load("fb_oauth")
I understand that I am not having access using my token despite authentication completion. Could someone please help.
Quick fix is just remove type = "application/x-www-form-urlencoded"
from fbOauth.R in RFacebook package. Because now Facebook returns response in JSON format.

Twitter OAuth fails with 'Unauthorized' error with R call

I setup a Twitter app, and gave Read,Write permissions. I noted down the API key and secret. Then, I called setup_twitter_oauth() as follows :
setup_twitter_oauth("key","secret")
[1] "Using browser based authentication"
Error in init_oauth1.0(self$endpoint, self$app,
permission = self$params$permission) :
client error: (401) Unauthorized
As seen, the request is rejected as Unauthorized. What could be the reason? Please let me know if further information is required to answer the question.
You appear to be missing some parameters from your call to setup_twitter_oauth. There are 4 parameters which you need:
consumer_key <- '...'
consumer_secret <- '...'
access_token <- '...'
access_secret <- '...'
setup_twitter_oauth(consumer_key,consumer_secret,access_token,access_secret)

Resources