19

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?

Igy
  • 43,312
  • 8
  • 86
  • 115
Subok Tao
  • 191
  • 1
  • 1
  • 3
  • 8
    You should change your app secret immediately - anyone who copied it before I edited your question can change your app's settings – Igy Apr 05 '12 at 10:02
  • still visible in revision history. – SachinGutte Jul 05 '13 at 11:13
  • the bounty is for @sumitkanoje, I searched like 3 (nightly) hours to get to this and it deserves a good ol reputation boost :-D – Bamboomy Mar 03 '18 at 01:42

3 Answers3

29

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.

sumitkanoje
  • 1,029
  • 12
  • 20
  • 1
    Most likely cause for getting that error is if your app is marked as 'Native / Desktop' instead of 'Web' in the app settings - in this case the app secret and app access token are untrusted because it's assumed you included the app secret in the app binary – Igy Jul 07 '12 at 09:02
  • This is enlightening. But, how can I get the app access token with the graph explorer? – Lance Mar 08 '13 at 03:05
  • @Lance No dear you cant get that, in graph explorer a token is generated but that token is limited for use of graph explorer only. – sumitkanoje Mar 12 '13 at 16:32
  • Okay. So, I have to write a php script to test sending notifications? – Lance Mar 12 '13 at 21:28
  • @Lance Yes you have to write your custom script for whatever you want to do. – sumitkanoje Mar 14 '13 at 17:21
  • Thanks a bunch. I'll look into it. – Lance Mar 14 '13 at 18:28
  • @Igy is there a downside of triggering the above error? Unless I am overlooking something, there is no way to tell by looking at the API call whether it requires user or app access token. However, I could simply wrap my PHP SDK to make another call using app access token if user access token has failed. – Gajus Oct 20 '13 at 17:40
  • On second thought, notifications api will unlikely be used anywhere else but in background process where only the app access token is available anyway. – Gajus Oct 20 '13 at 17:47
8

Read this link.

There is an alternative way:
You can provide App_Id and App_Secret instead of App_Access_Token.

So try this:

https://graph.facebook.com/100003429183160/scores?score=555&access_token=APP_ID|APP_SECRET

Hope it helps!! :)

abhi
  • 1,304
  • 16
  • 22
-1

Go to your setting => Basic => App Secret and use that key for secret key then it will generate access token which you can use in your app, hope it will work

raman rayat
  • 366
  • 4
  • 14