Akshay Bhosale
Akshay Bhosale

Reputation: 41

Leadgen Webhook: A user access token is required to request this resource

I want to get leads data from fb page forms. I am receiving Real time updates for leadgen webhook. Then I try to get leads details bu cURL like this

curl -X GET \ -d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v9.0/{lead-id}/

But it gives me error like "A user access token is required to request this resource."

My app is in live mode & I have approved permissions for leads retrieve from Facebook.

Anybody knows what am i missing? Please help.

Upvotes: 1

Views: 811

Answers (1)

Thiago
Thiago

Reputation: 91

The error message doesn't help much! In my case, I was using my own User (People) access token. I solved replacing it by a "System user" token, as described in this tutorial: https://developers.facebook.com/docs/marketplace/vehicles/retrieving-leads/#lead-apis-webhook

After creating the System User using the Business Configuration Panel, the cURL commands are:

  • Get System User ID: curl -G -d "access_token={SYSTEM USER TOKEN}" -d "appsecret_proof={PROOF SYSTEM USER + APP secret}" "https://graph.facebook.com/v9.0/{BUSINESS_ID}/system_users"
  • Add System User to page: curl -X POST -F "user={SYSTEM USER ID}" -F "tasks=["CREATE_CONTENT","MODERATE","ADVERTISE","ANALYZE","MANAGE"]" -F "access_token={SYSTEM USER TOKEN}" -F "appsecret_proof={PROOF SYSTEM USER + APP secret}" "https://graph.facebook.com/{PAGE_ID}/assigned_users"
  • Get Page(s): curl -X GET -G -d "access_token={SYSTEM USER TOKEN}" -d "appsecret_proof={PROOF SYSTEM USER + APP secret}" "https://graph.facebook.com/me/accounts"
  • Assign LEADGEN: curl -X POST -F "subscribed_fields=["leadgen"]" -F "access_token={page_token}" -F "appsecret_proof={proof Page+App secret}" "https://graph.facebook.com/{PAGE_ID}/subscribed_apps"
  • Get Lead: curl -X GET -G -d "access_token={PAGE_TOKEN}" -d "appsecret_proof={PROOF PAGE+APP secret}" "https://graph.facebook.com/{LEAD_ID}"

Upvotes: 2

Related Questions