daroczig / fbRads

Analyze and manage Facebook ads from R using this client library to access their Marketing APIs
GNU Affero General Public License v3.0
153 stars 57 forks source link

fbad_init Error: (#3) Application does not have the capability to make this API call #60

Closed alTagg3r closed 7 years ago

alTagg3r commented 7 years ago

Hello! Thanks to the contributors of this package! Looking forward to getting up and running. Early on I'm experiencing an minor issue with extracting the access code from tkn, but attempted a manual workaround for that (tkncopy). Later on, when trying to initiate via fbad_init, I'm getting a length error (included below). In summary, "(#3) Application does not have the capability to make this API call".

Appreciative of all advice - Thanks!

> library(httr)
> app <- oauth_app('facebook', 'my_id', 'my_secret')
> tkn <- oauth2.0_token(
+   oauth_endpoints('facebook'), app, scope = 'business_management',
+   type  = 'application/x-www-form-urlencoded', cache = FALSE)
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.
> tkn$credentials$access_token
NULL
> tkn$credentials
$`{"access_token":"my_access_token","token_type":"bearer","expires_in":5098355}`
[1] ""
> tkncopy <- "my_token" #manually extracted token from credentials list
> library(devtools)
> install_github("cardcorp/fbRads")
Skipping install of 'fbRads' from a github remote, the SHA1 (fc6cc5a7) has not changed since last install.
  Use `force = TRUE` to force installation
> acctid <- "my_ad_account_id"
> fbacc <- fbad_init(accountid = acctid, token = tkncopy)
ERROR [2017-06-01 16:53:45] URL:  https://graph.facebook.com/v2.8/act_377523705722721/
ERROR [2017-06-01 16:53:45] Method:  GET
ERROR [2017-06-01 16:53:45] Params:  List of 1
 $ fields: chr "name,account_id,account_status,age,amount_spent,balance,end_advertiser,funding_source,spend_cap,timezone_id,users"
ERROR [2017-06-01 16:53:45] Header: {"WWW-Authenticate":["OAuth \"Facebook Platform\" \"invalid_request\" \"(#3) Application does not have the capability to make this API call.\""],"Access-Control-Allow-Origin":["*"],"Pragma":["no-cache"],"Cache-Control":["no-store"],"x-fb-rev":["3057537"],"Content-Type":["application/json; charset=UTF-8"],"x-fb-trace-id":["CKY+xp03Lm4"],"facebook-api-version":["v2.9"],"Expires":["Sat, 01 Jan 2000 00:00:00 GMT"],"X-FB-Debug":["RDKfEF5KzJzM1RDQUFIlU7+1hF+d2qRx0x7Hvww01BBMkoX4c8iruxRLN/zSvd4rT8QarSK2MvQ+pavDni9+Jw=="],"Date":["Thu, 01 Jun 2017 23:53:45 GMT"],"Connection":["keep-alive"],"Content-Length":["152"],"status":["400"],"statusMessage":["Bad Request"]}
ERROR [2017-06-01 16:53:45] Body: {"error":{"message":"(#3) Application does not have the capability to make this API call.","type":"OAuthException","code":3,"fbtrace_id":"CKY+xp03Lm4"}}
Error in fbad_request(path = paste0("act_", accountid, "/"), method = "GET",  : 
  (#3) Application does not have the capability to make this API call.
daroczig commented 7 years ago

Regarding extracting the token manually, see #61

The error suggests that the app is not set up correctly. Can you please confirm you follow all steps from the readme? Can you also try adding "Marketing API" product?

alTagg3r commented 7 years ago

Thanks @daroczig for the reply! The jsonlite function i working beautifully. I followed all the steps in the readMe, but I didn't set up the MarketingAPI product properly in my fb dev account. Thanks for pointing me in the right direction!

daroczig commented 7 years ago

:+1:

Updated the README with this extra step.

muthukumar20 commented 3 years ago

{ "error": { "message": "(#3) Application does not have the capability to make this API call.", "type": "OAuthException", "code": 3, "fbtrace_id": "Acrg3f6l5EBNOME2hb-X4HV " } }

My json code is

{ "email": "testmymail@gmail.com", "role": "ADMIN", "business": "Gobi B" }

Plz help facebook marketing api