OAuthException 190 Madness!

1,887 views
Skip to first unread message

Chris R

unread,
Mar 29, 2014, 5:02:41 AM3/29/14
to res...@googlegroups.com
Thought simply posting to a page would be a breeze...  Hah!  Not in FB land I guess...

What the heck is this OAuthException 190?  I find lots of postings about people having trouble with it, but no solutions!

Any help would be GREATLY appreciated!!

Output:

Made object
array(3) { ["grant_type"]=> string(18) "client_credentials" ["client_id"]=> string(15) "597939046950715" ["client_secret"]=> string(32) "854f9cbc2ce4a358938f72d65163fe77" } 
Got token: "access_token=597939046950715|kNgOcsjynfvv9k_vJM1KMFuni1Y"
before call

FacebookApiException Object
(
    [result:protected] => Array
        (
            [error] => Array
                (
                    [message] => Invalid OAuth access token signature.
                    [type] => OAuthException
                    [code] => 190
                )

        )

[snipped]

Code:

<?php
require_once 'vendor/autoload.php'; //thank you Composer!

$appid = "597939046950715";
$appsecret = "854f9cbc2ce4a358938f72d65163fe77";

//Function to Get Access Token
function get_app_token($appid, $appsecret) {
	$args = array(
		'grant_type' => 'client_credentials',
		'client_id' => $appid,
		'client_secret' => $appsecret//,
		//'scope' => 'manage_pages,publish_stream'
	);
	
	var_dump($args);

	$ch = curl_init();
	$url = 'https://graph.facebook.com/oauth/access_token';
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_HEADER, false);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_POST, true);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
	$data = curl_exec($ch);

	return json_encode($data);
}

// Create FB Object Instance
$facebook = new Facebook(array(
    'appId'  => $appid,
    'secret' => $appsecret,
    'cookie' => false,
));

echo "Made object<br>";

//Get App Token
$token = get_app_token($appid, $appsecret);

echo "<br>Got token: $token<br>";

//Try to Publish on wall or catch the Facebook exception
try {
	$attachment = array(
		'method' => 'publish_stream',
		'message' => 'This is a message',
        'access_token' => $token,
        'name' => 'Attachment Name',
        'caption' => 'Attachment Caption',
        'link' => 'http://nyt.com',
        'description' => 'Description .....',
        'picture' => 'http://www.google.com/logo.jpg'
        //'actions' => array(array('name' => 'Action Text', 
        //'link' => 'http://apps.facebook.com/xxxxxx/'))
	);
	echo "before call";
	$result = $facebook->api('/'.$appid.'/feed/', 'post', $attachment);
	echo $result;
} catch (FacebookApiException $e) {		//If the post is not published, print error details
	echo '<pre>';
	print_r($e);
	echo '</pre>';
}

Chris R

unread,
Mar 29, 2014, 5:05:22 AM3/29/14
to res...@googlegroups.com
To be clear, I'm simply trying to post a message on a Page...  Nothing more...  So easy to do this kind of thing on Twitter.  Why is FB so hard?

Marcel Stör

unread,
Mar 29, 2014, 3:55:55 PM3/29/14
to res...@googlegroups.com
On 29.03.14 10:02, Chris R wrote:
> Thought simply posting to a page would be a breeze... Hah! Not in FB
> land I guess...
>
> What the heck is this OAuthException 190?

You must be really desperate...you do realize that this is Java-land and
not PHP-land, don't you?

Anyway, I understand your frustration. FB documents their error codes
AND the provide a sample response. Yet the error code 190 in sample
response is /not/ documented :(
https://developers.facebook.com/docs/graph-api/using-graph-api/#receiving-errorcodes

Are you familiar with
https://developers.facebook.com/docs/facebook-login/access-tokens/#apptokens:
"if your app is set to Native/Desktop in the Advanced settings of your
App Dashboard and therefore will not work with API calls".

However, I believe the real problem here is that you need a user token
instead of an app token to post a message to a page.

Cheers,
Marcel

--
Marcel Stör, http://frightanic.com
Couchsurfing: http://www.couchsurfing.com/people/marcelstoer
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

Chris Rowan

unread,
Mar 29, 2014, 6:07:40 PM3/29/14
to res...@googlegroups.com
Marcel - thanks for the reply and leads.  Nope, since the group was named "restfb" I thought it was about FB REST.  Sorry about that.

The app is not set to Native/Desktop.

The user token versus app token sounds like a promising lead!

Thanks so much.


--
You received this message because you are subscribed to a topic in the Google Groups "RestFB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/restfb/u27RfzBEfQQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to restfb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages