pablobarbera / Rfacebook

Dev version of Rfacebook package: Access to Facebook API via R
http://cran.r-project.org/web/packages/Rfacebook
350 stars 250 forks source link

(HTTP 400). Failed to get an access token. #102

Open a0903624 opened 7 years ago

a0903624 commented 7 years ago

Hi all,

I am still having a problem with access to my token: Waiting for authentication in browser... Press Esc/Ctrl + C to abort 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.

I've already tried to fix this issue as you suggest by installing httr version = "1.1.0" but I got another error: Rfacebook requires httr version 1.2.0 or greater

I used this code: library(devtools)

install_github("Rfacebook", "pablobarbera", subdir = "Rfacebook") library(Rfacebook)

fb_oauth <- fbOAuth(app_id = "xxx", app_secret = "xxx", extended_permissions = TRUE)

and here my sessioninfo() R version 3.3.1 (2016-06-21) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1

locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 [4] LC_NUMERIC=C LC_TIME=German_Germany.1252

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

other attached packages: [1] Rfacebook_0.6.11 httpuv_1.3.3 rjson_0.2.15 httr_1.2.1 devtools_1.12.0 RMySQL_0.10.9
[7] DBI_0.5-1

loaded via a namespace (and not attached): [1] R6_2.2.0 tools_3.3.1 withr_1.0.2 curl_2.3 Rcpp_0.12.6 memoise_1.0.0 git2r_0.15.0 [8] digest_0.6.10

Many thanks in advance!

ghost commented 7 years ago

Hi! Rfacebook made it past its dev status. Have you tried it with library(Rfacebook)?

Best,

Marvin

a0903624 commented 7 years ago

with Rfacebook_0.6.11

pablobarbera commented 7 years ago

@a0903624 I honestly have no idea why this is happening. I have the same versions of the packages installed and I cannot replicate the error. Perhaps a problem with your browser or internet connection? Sorry I cannot help more! I'll leave this issue open in case someone else can help you.

nikolasj5 commented 7 years ago

I've been through some similar problem and i think the cause is actually the browser. After some debugging i found the function browseURL from httr crashing, then i changed the call to "browser=NULL" and it worked just fine. Defining a browser works too.

My OS is Windows also, maybe in a Unix based the problem doesn't occur.

nikolasj5 commented 7 years ago

I could solve it on mine! Try calling options("browser" = NULL) before fbOauth().

Should I make a pull request?

pablobarbera commented 7 years ago

@nikolasj5 Sorry I'm only replying to this now. I'm trying to run the function with browser=NULL, but then it doesn't work for me (on Mac). It says Error in utils::browseURL(hu$url) : 'browser' must be a non-empty character string . Were you able to make it work? Do you specify the browser manually somewhere else?

nikolasj5 commented 7 years ago

Yes, it worked fine on Windows.

I would have to search the references but as far as i can remember the way it was before didn't work only on Windows, because it returns the default browser just if the parameter is null. Em 24/05/2017 21:51, "Pablo Barberá" notifications@github.com escreveu:

@nikolasj5 https://github.com/nikolasj5 Sorry I'm only replying to this now. I'm trying to run the function with browser=NULL, but then it doesn't work for me (on Mac). It says Error in utils::browseURL(hu$url) : 'browser' must be a non-empty character string . Were you able to make it work? Do you specify the browser manually somewhere else?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pablobarbera/Rfacebook/issues/102#issuecomment-303892435, or mute the thread https://github.com/notifications/unsubscribe-auth/AK3jviKldrzVMOsMU9iwvlUOcUhmTwY-ks5r9NCegaJpZM4LhvCi .

ThomasWilli commented 6 years ago

Same issue here: Bad Request (HTTP 400). Failed to get an access token. and same error on Mac: Error in utils::browseURL(hu$url) : 'browser' must be a non-empty character string Did you solve this by any means?

nikolasj5 commented 6 years ago

I've "solved" it by adding options("browser" = NULL) in the beginning of fbOAuth in Rfacebook/R/fbOAuth.R file.

ThomasWilli commented 6 years ago

Hi, me too! And even without the options("browser"=NULL) version. When looking at your app https://developers.facebook.com/apps you see «Products» on your left side. Click there and add http://localhost:1410/ under Valid OAuth redirect URIs too. Worked for me.

mmcr85 commented 6 years ago

ThomasWilli is right! that works for me.

AncaElena10 commented 6 years ago

Nothing seems to work for me..

 Waiting for authentication in browser...
    Press Esc/Ctrl + C to abort
    Authentication complete.
    Error in init_oauth2.0(self$endpoint, self$app, scope = self$params$scope,  : 
    Bad Request (HTTP 400).
rajibstats commented 6 years ago

Same problem for me too..

Copy and paste into Site URL on Facebook App Settings: http://localhost:1410/ When done, press any key to continue... 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, : Bad Request (HTTP 400). Failed to get an access token.

Ochibobo commented 6 years ago

rajibstats you should also do what ThomasWilli has said: "When looking at your app https://developers.facebook.com/apps you see «Products» on your left side. Click there and add http://localhost:1410/ under Valid OAuth redirect URIs too. Worked for me. " Just don't set the "Enforce HTTPS" to yes. It has worked for me.

hornelius commented 6 years ago

Ok, my problem is slightly weirder - this has worked nicely for me for a while now - never any problems - until today. I'm trying to run the same piece of code, but on a remote machine (so that I can set it up on a scheduler) - all of a sudden, I get the same error as above.

Any ideas? Could this be because it's on a remote machine and if so what specifically might be making it fail?

MVATFM commented 6 years ago

Hi, I have the same problem and I do everything you recommend me in this post and when I configure eveything this appear: Invalid Scopes: user_relationships, publish_actions. This message is only shown to developers. Users of your app will ignore these permissions if present. Please read the documentation for valid permissions at: https://developers.facebook.com/docs/facebook-login/permissions

Please help me!

krinya commented 6 years ago

Same here for me it is not working. With the same error! Also, I cant set http at the "Valid OAuth Redirect URIs" field at Facebook's developer site.