Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

twitteR throws Forbidden error after entering twitter API PIN

I am trying to analyze some tweets using R and twitteR package. The handshake and registration code seems to work properly and I get the authorization link from R. However, when I enter the PIN obtained from https://api.twitter.com/oauth/authorize I get a "Forbidden Error." Any help is appreciated.

The Code:

TwitterOAuth<-function(){
  reqURL <- "https://api.twitter.com/oauth/request_token"
  accessURL <- "http://api.twitter.com/oauth/access_token"
  authURL <- "http://api.twitter.com/oauth/authorize"
  consumerKey <- "xxxxxxxxxxxxxxxx"
  consumerSecret <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  twitCred <- OAuthFactory$new(consumerKey=consumerKey,
                             consumerSecret=consumerSecret,
                             requestURL=reqURL,
                             accessURL=accessURL,
                             authURL=authURL)
  options(RCurlOptions = list(cainfo = system.file("CurlSSL", "cacert.pem", package =  "RCurl")))
  twitCred$handshake()
  registerTwitterOAuth(twitCred)
}

The Response:

TwitterOAuth() To enable the connection, please direct your web browser to: http://api.twitter.com/oauth/authorize?oauth_token=X0AwET4FXBC7YRIWWN3iF61WFNE1DjxbfibqtfFjgcc
When complete, record the PIN given to you and provide it here: 1998913
Error: Forbidden

My sessionInfo()

R version 3.0.2 (2013-09-25) Platform: x86_64-w64-mingw32/x64 (64-bit)

locale: [1] LC_COLLATE=Turkish_Turkey.1254 LC_CTYPE=Turkish_Turkey.1254 LC_MONETARY=Turkish_Turkey.1254 [4] LC_NUMERIC=C LC_TIME=Turkish_Turkey.1254

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] twitteR_1.1.7 rjson_0.2.13 ROAuth_0.9.3 digest_0.6.4 RCurl_1.95-4.1 bitops_1.0-6

loaded via a namespace (and not attached): [1] tools_3.0.2

like image 454
user3265306 Avatar asked Feb 03 '14 10:02

user3265306


People also ask

Why is Twitter API not working?

There was a problem authenticating your request. This could be due to missing or incorrect authentication credentials. This may also be returned in other undefined circumstances. Check that you are using the correct authentication method and that your credentials are correct.

What is error forbidden on Twitter mean?

403. Forbidden. The request is understood, but it has been refused or access is not allowed. An accompanying error message will explain why. This code is used when requests are being denied due to update limits .

Can I use Twitter API without authentication?

You can do application-only authentication using your apps consumer API keys, or by using a App only Access Token (Bearer Token). This means that the only requests you can make to a Twitter API must not require an authenticated user.


1 Answers

Change your access URL from http to https.

like image 87
Martin Avatar answered Nov 15 '22 08:11

Martin