Facebook Messenger API : An active access token must be used to query information about the current user

12,077

Solution 1

The error message shows that you were trying to query the information about the current user communicating with your char bot. The API end point which serves the user information is:

https://graph.facebook.com/v2.6/USER_ID_HERE?fields=first_name,last_name,profile_pic&access_token=PAGE_ACCESS_TOKEN_HERE

And as per the documentation, you need to make a GET request (not POST) to this end point.

You can personalize the conversation using the person's name or profile pic from the User Profile API. In order to get this information, make a GET request to https://graph.facebook.com/v2.6/?fields=first_name,last_name,profile_pic&access_token=. Read more details in the Send API reference. https://developers.facebook.com/docs/messenger-platform/implementation#user_profile_api

Solution 2

Try setting the "Authorization" header with value "Bearer PAGE_ACCESS_TOKEN" instead of "access_token: PAGE_ACCESS_TOKEN"

Share:
12,077
kaid
Author by

kaid

code reader,writer

Updated on July 26, 2022

Comments

  • kaid
    kaid almost 2 years

    I'm following the development guide here: https://developers.facebook.com/docs/messenger-platform/quickstart

    I've setup my server and the webhooks. When I try to make a POST request to the facebook graph api, I get the following response:

    {"response":{"statusCode":400,"content":"{\"error\":{\"message\":\"An active access token must be used to query information about the current user.\",\"type\":\"OAuthException\",\"code\":2500,\"fbtrace_id\":\"GHWSIH8OBGm\"}}","headers":{"www-authenticate":"OAuth \"Facebook Platform\" \"invalid_request\" \"An active access token must be used to query information about the current user.\"","access-control-allow-origin":"*","pragma":"no-cache","cache-control":"no-store","facebook-api-version":"v2.6","expires":"Sat, 01 Jan 2000 00:00:00 GMT","content-type":"text/javascript; charset=UTF-8","x-fb-trace-id":"GHWSIH8OBGm","x-fb-rev":"2296043","vary":"Accept-Encoding","x-fb-debug":"4KebPKo5T+Al/88Z7DWtZ8ROawIB3cZFLp65OVi/soTB6hOHstvXox5czalYj45FdI+2r+MQwNh9PHur5uGSbQ==","date":"Wed, 20 Apr 2016 23:45:26 GMT","transfer-encoding":"chunked","connection":"keep-alive"},"data":{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500,"fbtrace_id":"GHWSIH8OBGm"}}}}
    

    I'm using the Page Access Token provided by the apps page. I used the fb token validator to validate that the token has not expired.

    I appreciate any help with this.

  • wortwart
    wortwart about 8 years
    I've got the same problem, and the demo I try to build definitely uses POST to send data to the user via messenger. The problem seems to be that Facebook doesn't even let you play around or test your chatbot before they reviewed the app.
  • astiefel
    astiefel almost 8 years
    what is the USER_ID_HERE? is that /me?
  • Mukarram Khalid
    Mukarram Khalid almost 8 years
    It's the 'sender id' you receive with the message on your webhook.
  • Atiq
    Atiq over 7 years
    same problem and USER_ID_HERE is me