Rfacebook package, "fbOAuth(appid, appsecret)" fails to get an access token. Returns bad request (HTTP 400)

413 views Asked by At

I am trying to scrape some text from fb using the 'Rfacebook' package. Even after installing Rfacebook & tm, running relevant libraries (Rfacebook, httr, tm, and httpuv), fboAuth(appid, appsecret) is failing to get the reqd. access token. Please see the code and ensuing error below:

install.packages("Rfacebook")
install.packages("tm")
library(devtools)
library(Rfacebook)
library(httr)
library(httpuv)
library(tm)

appid <- 123
appsecret <- 'mysecret123'

fboauth <- fbOAuth(appid, appsecret, extended_permissions = T)

Which returns Copy and paste into Site URL on Facebook App Settings: http://localhost:1410/ When done, press any key to continue...

Upon pasting the redirect url in the cell here, a browser opened.

And, although the browser displayed "Authentication complete. Please close this page and return to R.", an error msg was returned in the RStudio console (attached below.) Again, I tried this with Safari as well as Chrome as default browsers - no change.

Authentication complete. Error in init_oauth2.0(self$endpoint, self$app, scope = self$params$scope, : Bad Request (HTTP 400). Failed to get an access token.

Any help in resolving this is truly appreciated!

Best,

S

p.s. Using R-Studio v3.3.2 on a Mac (OS Sierra.)

1

There are 1 answers

0
Titan4 On

Try the following a) remove httr package b) remove RCurl package c) remove RFacebook d) Reinstall httr , then RCurl, and then RFacebook e) get the latest version of R studio f) After you authenticate, and when you get the message Copy and paste into Site URL on Facebook App Settings: http://localhost:1410/ When done, press any key to continue... You may want to do save(user_fbOauth) where user_fbOauth are your credentials g) then pass them to any other request

I have tried this and dont see any issues