Search code examples
rfacebook-graph-apioauthoauth-2.0httr

How to use the oauth2.0_token function from httr package with facebook API?


I have a collection of facebook functions that relies on the httr package.

The usual procedure is that one has to set oauth app specs and facebook endpoints. Until recently this worked like a charm but now when I try to get the token by the oauth2.0_token function I get the error:

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

You see my code below:

facebook_app <- oauth_app("facebook", key = "XXXX", secret = "YYYY")
  # end point
  facebook_ep <- oauth_endpoint(
    authorize = "https://www.facebook.com/dialog/oauth",
    access = "https://graph.facebook.com/oauth/access_token")
  # token from endpoint and oauth
  fb.token <- oauth2.0_token(facebook_ep, facebook_app, user_params = facebook_ep)

I have been to various posts and forums but I have not had luck in finding a solution yet.


Solution

  • Solved by settting:

    Sys.setenv("HTTR_SERVER_PORT" = "1410/")