0

I'm trying to retrieve Facebook Lead using graph API using App Token to be long time token. But the graph API return the following error

{
  "error": {
    "message": "A user access token is required to request this resource.",
    "type": "OAuthException",
    "code": 102,
    "fbtrace_id": ""
  }
}

I want to retrieve it with app token, any ideas.

Thanks in advance.

Hussein Fawzy
  • 525
  • 1
  • 8
  • 15
  • I'm having the same issue. Are you page owner? E.g. I'm not the owner of page where lead was generated but I have access to page so I have subscribed page to app and was trying to retrieve lead by leadgen_id using app access token, but received the same error. I'm thinking maybe it's because the one who registered page to app didn't had right access and because of that app doesn't have it to? – simkusr Mar 18 '19 at 06:11

1 Answers1

0

I have found solution. If you need to retrieve page leadgen then you must use page access token where ad was created and generated, otherwise it doesn't work.

How I have solved this case:

  1. Connect to application and logging in with user
  2. Exchange retrieved user short (1-2h) access token to long lived access token (~60 days if not using access token, else if you use it daily it will never expire)
  3. call facebook api to retrieve user pages thru server using new users long lived token (this way page access tokens will have ~60 days and if use it daily then it will never expire)
  4. when webhook sends you leadgen_id use server call to retrieve lead data using not app access token but long lived page access token that you have saved in database. As webhook sends leadgen_id, page_id and etc, you can connect page access token to page id and then with webhook data you can get correct access token and retrieve details about the lead from facebook.

For me this approach worked. I'm using Python to communicate in server side.

Comment or message me if you'r having issues.

simkusr
  • 770
  • 2
  • 11
  • 20