Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

This method must be called with an app access_token

After days of searching the forums/net, I still couldn't get this to go away and use the SCORE graph api

{
  "error": {
  "message": "(#15) This method must be called with an app access_token.", 
  "type": "OAuthException", 
  "code": 15
  }
}

On the graph api explorer i tried using this (with publish_actions permission activated & POST selected):

https://graph.facebook.com/100003429183160/scores?score=555&access_token=APP_ACCESS_TOKEN

Having no luck :(

I have done the following:

• Set my app as a GAME, the basic info, setup the Auth Dialog

• Setup the Open Graph type, object, aggregation

• Use/Verify the right APP ACCESS_TOKEN (not the user access_token) via Access Token Tool

• Use the publish_actions permission

• Made sure it's using POST as method

• Tried appID|appSecret as an app access_token

• Verified that I indeed installed the app

• Was able to post to a wall via graph api, pull friends list and photos, etc.

Any clues what else could cause this not to run with the Graph API Explorer?

like image 663
Subok Tao Avatar asked Mar 21 '12 23:03

Subok Tao


People also ask

How can I get access token of Facebook?

Obtain User Access TokenIn Facebook App, select an app used to obtain the access token. In User or Page, select User Token. Under Permissions, check ads_read . Click Generate Access Token.

What is access token in Facebook API?

An access token is an opaque string that identifies a user, app, or Page and can be used by the app to make graph API calls. When someone connects with an app using Facebook Login and approves the request for permissions, the app obtains an access token that provides temporary, secure access to Facebook APIs.

How do I get a short live access token?

Go to https://developers.facebook.com/tools/explorer/ and select your app from the first drop down menu, in the left. Click on the button "Get access token", and in the "Select Permissions" window, click in "Extended Permissions" and check manage_pages and publish_stream, and click in "Get Access Token" blue button.


1 Answers

Answer:-

Actually for using SCORE Graph API you need the "Application access token" which is different than a normal access token

So if you want your task to be done GET an Application access token by using the following script.......

And then replace the generated application_access_token with old access_token, that's it

$APPLICATION_ID = "APP_ID";
$APPLICATION_SECRET = "APP_SECRET";

$token_url =    "https://graph.facebook.com/oauth/access_token?" .
                "client_id=" . $APPLICATION_ID .
                "&client_secret=" . $APPLICATION_SECRET .
                "&grant_type=client_credentials";
$app_token = file_get_contents($token_url);

After getting this application access token you can easily do this task.

When You Need An Application Access Token

You need to use a Facebook application access token when you have a process that acts on behalf of the application, rather than on behalf of a particular user. This happens when you access your Facebook Insights data for your app via the graph, and also when you want to create test Facebook users for your app.

Sadly, the documentation for this is buried in the authentication guide for the Facebook graph API.

like image 148
sumitkanoje Avatar answered Nov 15 '22 21:11

sumitkanoje