Rfacebook icon indicating copy to clipboard operation
Rfacebook copied to clipboard

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

Open a0903624 opened this issue 8 years ago • 17 comments

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!

a0903624 avatar Jan 12 '17 13:01 a0903624

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

Best,

Marvin

ghost avatar Jan 12 '17 16:01 ghost

with Rfacebook_0.6.11

a0903624 avatar Jan 12 '17 17:01 a0903624

@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.

pablobarbera avatar Jan 21 '17 23:01 pablobarbera

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 avatar Mar 08 '17 19:03 nikolasj5

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

Should I make a pull request?

nikolasj5 avatar Mar 10 '17 18:03 nikolasj5

@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?

pablobarbera avatar May 25 '17 00:05 pablobarbera

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á" [email protected] 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 .

nikolasj5 avatar May 25 '17 15:05 nikolasj5

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?

ThomasWilli avatar Nov 07 '17 08:11 ThomasWilli

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

nikolasj5 avatar Nov 08 '17 16:11 nikolasj5

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.

ThomasWilli avatar Nov 09 '17 08:11 ThomasWilli

ThomasWilli is right! that works for me.

mmcr85 avatar Nov 15 '17 19:11 mmcr85

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).

AncaElena10 avatar Jan 09 '18 18:01 AncaElena10

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.

rajibstats avatar May 13 '18 06:05 rajibstats

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.

Ochibobo avatar May 18 '18 15:05 Ochibobo

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?

hornelius avatar Jul 04 '18 06:07 hornelius

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!

MVATFM avatar Sep 06 '18 12:09 MVATFM

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.

krinya avatar Sep 07 '18 12:09 krinya