fbAuthenticate: Authenticate

Description Usage Arguments Details Author(s) Examples

Description

Authenticate through Facebook Graph API with your facebook application which you can create at https://developers.facebook.com/apps

Usage

1
2
fbAuthenticate(app.id, app.secret, scope = "ads_management",
  app.name = "optional")

Arguments

app.id

ID of your facebook app. See facebook apps

app.secret

App secret of facebook app. See facebook apps

scope

General permissions, either ads_management or ads_read, defaults to the former, see permissions.

app.name

Name of your app, optional.

Details

httpuv: Consider loading the httpuv package to avoid issues, install.packages("httpuv");library(httpuv)

There are two different ways of making authenticated requests. One is to obtain a temporary access token from https://developers.facebook.com/tools/explorer, the other is to use a long-term token provided by this very function.

Either way you will have to create an app; go to https://developers.facebook.com/apps, register as a developer and create a new app. You will also need a verified Facebook account.

To get the short-term token:

  1. Go to facebook's Graph API Explorer: https://developers.facebook.com/tools/explorer

  2. Select your app in the top right corner (defaults to "Graph API Explorer")

  3. Then in the dropdown underneath hit "Get Token" and select "Get User Access Token"

  4. In the popup navigate to "Extended Permissions" and select "ads_management" and/or "ads_read"

  5. Click "Get Access Token" and allow the app in the following popup

  6. Copy and Save the token in your R sesssion.

However, this token has a 2-hour lifetime by default and thus needs to be renewed frequently. The alternative is to create an OAuth token using this function and your "App ID" and "App Secret"

Author(s)

John coene jcoenep@gmail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
 
## Not run: 
# run authentication with your app details
fbOAuth <- fbAuthenticate(app.id = "1234567890123456", 
                          app.secret = "16xx79321xx0130x2x10a08x3e2x80xx", 
                          scope = "ads_management")
print(fbOAuth)
<Token>
<oauth_endpoint>
 authorize: https://www.facebook.com/dialog/oauth
 access:    https://graph.facebook.com/oauth/access_token
<oauth_app> optional
 key:    123456789012345
 secret: <hidden>
 <credentials> access_token, expires
---

## End(Not run)

JohnCoene/fbadsinsightsr documentation built on May 28, 2019, 12:55 p.m.