tattertron
tattertron

Reputation: 11

Meta App Access Token unable to retrieve leads

I am doing some development for my app and am trying to retrieve leads created using the leads testing tool. I have tested with page access token and its working fine. However, when I try to fetch lead data using app access token, I hit this error.

"(#3) Apps in dev mode should only access leads submitted from App special roles (testers, developers, admin)",

The app itself is already in live mode, so I don't see any reason why we are hitting this error.

What I did: Sent a GET request using the endpoint https://graph.facebook.com/v17.0/ using app access token.

What I expected: To receive lead data as specified in the documentation - https://developers.facebook.com/docs/marketing-api/guides/lead-ads/retrieving/

What I received:

{ "error": { "message": "(#3) Apps in dev mode should only access leads submitted from App special roles (testers, developers, admin)", "type": "OAuthException", "code": 3, "fbtrace_id": } }

Upvotes: 1

Views: 896

Answers (1)

Maria Mozgunova
Maria Mozgunova

Reputation: 51

I was struggling with the same issue and I managed to figure out the solution

tldr; for the API call to succeed, you need to make a call with the user access token.

So I submitted the lead using the Lead Ads Testing Tool but was not able to retrieve it with the Marketing API because of the exact error (#3) Apps in dev mode should only access leads submitted from App special roles (testers, developers, admin)

This quote is more for the context. The Meta Lead Ads guide reads the following:

Limitations

Starting in Marketing API v9.0, you will not be able to retrieve leads if your app is in Development mode. For testing purposes, Development mode app users can access leads submitted by someone with a role in that same app. See App Roles.

The Retrieving Leads docs says:

To read all lead data and ad level data, you will need:

  • A Page or User access token requested by a person who can advertise on the ad account and on the Page
  • The ads_management permission
  • The leads_retrieval permission
  • The pages_show_list permission
  • The pages_read_engagement permission
  • The pages_manage_ads permission

I then generated an access token with the permissions mentioned above using Graph API Explorer as noted on the Authentication page for Marketing API:

Obtain User Access Token

  1. Go to Graph API Explorer.
  2. In Facebook App, select an app used to obtain the access token.
  3. In User or Page, select User Token.
  4. Under Permissions, check ads_read.
  5. Click Generate Access Token. The box on top of the button is populated with the access token.
  6. Store that token for later use.

Then I made a call to the Marketing API with the generated user token and managed to retrieve the lead by its id.

Hope this helps!

Upvotes: 0

Related Questions