Python - Facebook Open Graph API Error: An active access token must be used to query information about the current user
<p>I am trying to fetch the details of a facebook page. For ex: <a href="https://graph.facebook.com/rio2016/posts?access-token=xxxxx" rel="nofollow">https://graph.facebook.com/rio2016/posts?access-token=xxxxx</a>. Now I generated a token in graph API explorer. If I use that token in Graph API explorer then I am able to get the data from above url. In fact, if I type the above url with the generated token in browser, I still get the data. But I am writing a python script in flask to achieve the same and I get the following error:</p>

<pre><code>'message': 'An active access token must be used to query information about the current user.', 'fbtrace_id': 'Hnp1lPb3dXu', 'code': 2500, 'type': 'OAuthException'
</code></pre>

<p>Following is my python script:</p>

<pre><code>def fb_crawler():
    key = 'xyz'
    parameters = {'access-token': key}
    r = requests.get('https://graph.facebook.com/rio2016/posts', params = parameters)
    result = r.json()
    for i, v in result.items():
        print(i)
        print(v)
    return result
</code></pre>

<p>It should simply be a GET request as in browser same url return desired result but not when used with a python script. Can someone please guide me here, what is going wrong? Thank you.</p>

<p>Thank you. Finally I figured out the error in the code. Now I can fetch data with GET requests.</p>

<p>Revised Code:</p>

<pre><code>def fb_crawler():
    key = 'xyz'
    parameters = {'access_token': key}
    r = requests.get('https://graph.facebook.com/rio2016/posts', params = parameters)
    result = r.json()
</code></pre>

<p>Error: It is access_token instead of access-token.</p>

python facebook facebook-graph-api