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

(#190) This method must be called with a Page Access Token #174

Closed diegocgaona closed 6 years ago

diegocgaona commented 6 years ago

I'm having a error when I try to get data:

Error in callAPI(url = x, token = token) : 
  (#190) This method must be called with a Page Access Token

The process of creation of the token is OK, but when I try to access the API data, I receive this error (i'm using the last official version of RFacebook.)

I followed the tutorial (it worked until now): http://thinktostart.com/analyzing-facebook-with-r/

And used:

fb_oauth <- fbOAuth(app_id="XXXXXXXXXX", app_secret="XXXXXXXXXXXXXX", extended_permissions = T)
save(fb_oauth, file="fb_oauth")
load("fb_oauth") 

Then I try to get data, example:

fb_page_fans <- tail(getInsights(object_id = fbpage_id, token = fb_oauth, metric = c('page_fans'), 
                                  period = c('lifetime')), n = 1)

And get the error above... The app is already configured with localhost too.

Any idea? I think I need to create a different token, a Page Token, but I don't know how.

pippo-sci commented 6 years ago

I'm experiencing the same error. It asks me for page access token, but I use the temporary token because the fb_oauth isn't working for a while.

adrauc commented 6 years ago

Yes, Facebook had some changes. Can be fixed: -Go to the dashboard of your app -left: click on "Facbook Login" -> Settings -Now paste in the field "Valid OAuth redirect URIs" http://localhost:1410/ -fbOAuth() should now work again in R again

diegocgaona commented 6 years ago

Hi @adrauc !

Thanks! I already did that (because FB show a message about the change in redirect) before I opened the issue. I tried it and other changes, but without success. Here is my config, any other option is wrong?

image

pippo-sci commented 6 years ago

@diegocgaona you should use getPageToken instead fb_oauth. Try:

token <- getPageToken("yourpage", fb_oauth) fb_page_fans <- tail(getInsights(object_id = fbpage_id, token = token, metric = c('page_fans'), period = c('lifetime')), n = 1)

diegocgaona commented 6 years ago

Many thanks @anankeman ! Worked fine for me, I hope it will help the others.

setegonz commented 5 years ago

@diegocgaona @anankeman I'm trying to use the getInsights function and getting the This method must be called with a Page Access Token error.

I tried fb_oauth <- fbOAuth(app_id=..... and get this error

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.

I then tried to use the generated token via https://developers.facebook.com/tools/explorer/ With that token, I'm able to use the getPage function but getInsights give me the following error: This method must be called with a Page Access Token even when the graph api explorer says that I have that permission 4B21F95F-3290-492F-801F-E5AC91BAFBF5

Do you know what I'm doing wrong?

diegocgaona commented 5 years ago

@setegonz sorry, i'm not using it anymore. Probably is something with the permissions or API version, Facebook was making my life hard too, changing the API and the access...

setegonz commented 5 years ago

@setegonz sorry, i'm not using it anymore. Probably is something with the permissions or API version, Facebook was making my life hard too, changing the API and the access...

Sem problemas. Obrigado!