I'm getting the below error when I logged out of facebook but still logged in and do a refresh on my site.

Facebook API exception Invalid OAuth 2.0 Access Token.
#0 .../sites/all/modules/fb/facebook-platform/php/facebook.php(469): Facebook->_restserver(Array)
#1 .../sites/all/modules/fb/fb.module(296): Facebook->api(Array)
#2 .../sites/all/modules/my_modules/my_modules.module(117): fb_fql_query()
#3 .../includes/module.inc(462): my_modules_block(Object(Facebook), 'SELECT uid FROM...')
#4 .../modules/block/block.module(499): module_invoke()
#5 .../includes/theme.inc(1626): block_list('view', 'fb_users_list_b...')
#6 .../includes/theme.inc(656): theme_blocks(my_modules_...', Array)
#7 .../includes/theme.inc(1820): theme()
#8 .../includes/theme.inc(697): template_preprocess_page(my_modules', 'block', 'view', 'fb_users_list_b...')
#9 .../sites/all/modules/panels/plugins/tasks/panel_page.inc(202): theme()
#10 .../sites/all/modules/ctools/delegator/plugins/tasks/page.inc(335): panels_panel_page_execute('fb_block')
#11 .../includes/menu.inc(348): delegator_page_execute('fb_block')
#12 .../index.php(18): menu_execute_active_handler()
#13 {main}
$_REQUEST:
Array
(
.... truncated ...
)

REQUEST_URI:
/

Please help. Am I supposed to get this error? Or is there an error in my configuration? How can I show the homepage instead of the white screen with these errors? Although it gets away but it takes time before the home page loads again. Thanks in advance.

Comments

Dave Cohen’s picture

Component: User interface » Code
Priority: Critical » Normal

You say you are logged out of facebook, so I suspect this is the correct behavior, rather than an error. Facebook is telling you that you can't make the FQL query when the user has not authorized the app (which is the case when not logged into facebook).

If you really need to make such a query when a user is not logged in, you'll need the user to approve the off-line access extended permission.

krem’s picture

Since today I am having the same error... Afterward I tried to upgrade fb module to latest and facebook sdk as well but still the same error. Furthermore, I tried to compltely uninstall everything and now I can't create a new facebook app in fb module ! Am I the only one to get this problem ? If it's the case, I must be doing something wrong...

creatile’s picture

Hello, I have the same problem. Can't create new facebook application with FB 3x and latest sdk.

Should i configure specific parameters to make it work properly on my facebook application account ?

Or
I may not use the latest sdk release ?

strae’s picture

Same problem here, i updated the module today with the version of yesterday (28 September 2010).

After the update, the cron report this error:

Failed to get application properties (myappname) from Facebook: Invalid OAuth 2.0 Access Token 190
Unable to get application properties. Confirm both apikey and secret.

I checked twice the app apikey, secret and id, i uninstalled the module, deleted the facebook app, then reinstalled the module, recreate a new facebook app, but when i try to add it in `admin/build/fb/fb_app_create` i allways got these errors.

The strange things is that i've tryed to use the 'old' 6.x-3.x-dev version that used to work till yesterday, but the problem persist... so i have the doubt that the issue is not related to the module (used to work till yesterday!) but with facebook auth... could be that facebook has changed they'rs auth method, or somethings like?

chrisjlock’s picture

Title: Facebook API exception Invalid OAuth 2.0 Access Token. » Same issue

Facebook Devel shows:

Array
(
[fb_devel] => Array
(
[FB_OP_POST_INIT] => 51
)

[dblog_overview_filter] => Array
(
)

[messages] => Array
(
[error] => Array
(
[0] => Failed to get application properties (Ap Label) from Facebook: Invalid OAuth 2.0 Access Token 190
[1] => Unable to get application properties. Confirm both apikey and secret.
)

)

)

strae’s picture

Title: Same issue » Failed to get application properties (Ap Label) from Facebook: Invalid OAuth 2.0 Access Token 190/Unable to get application prop

Please dont edit the issue title when submitting new comments.

strae’s picture

Maybe i got it.

I analyzed the URI generated in fb.module file at fb_call_method() function, i think the problem is here;

This function encode some characters (commas for example), so the URI it spit out is (for example):

properties=about_url%2Capplication_name%2Cedit_url%2Cauthorize_url%2Cuninstall_url%2Ccanvas_name%2Cconnect_url&access_token=123456789%257123456789&api_key=123456789&format=json-strings

I copy'n'pasted this in my browser, and i got the OAuth error.

So, i replaced the url_encoded chars with the originals:

properties=about_url,application_name,edit_url,authorize_url,uninstall_url,canvas_name,connect_url&access_token=123456789%7123456789&api_key=123456789&format=json-strings

Then, used this directly in the browser: it works.

Try out by your own, replace

  $url = url("https://api.facebook.com/method/{$method}", array(
               'query' => $params,
             ));

with

  $url = 'https://api.facebook.com/method/' . $method
          . '?access_token=' . $params['access_token']
          . '&api_key=' . $params['api_key']
          . '&format=' . $params['format']
          . '&properties=' . $params['properties'];

into your fb.module file inside the function fb_call_method (about line 301), then it should work.

to all copy'n'paste guys: please note that this is not a patch, and the url i build do not take care about input satinization, this 'solve' this issue but could probably open many others; DO NOT USE MY EXAMPLE IN PRODUCTION

Edit: After several attempts, i got that the problem (im my case, check your own) is the %7 char in the access_token var that get encoded in %257

strae’s picture

Category: support » bug
Dave Cohen’s picture

Thanks for the detail. To be honest, I'm puzzled why a problem like this would just start happening. I'd be surprised if facebook made a change that caused this (but not too surprised).

lmakarov’s picture

Can report the same issue. Started today. No changes or updates were done.
Sounds like this is some change or issue on FB side...?

nrosell’s picture

subscribing.
#7 solved my problem.
Thanks a lot.

Dave Cohen’s picture

Assigned: Unassigned » Dave Cohen
Priority: Normal » Major

Yeah, I see it too. Definitely a change on the facebook side.

I appreciate the details from Strae. Will try to get something committed soon.

Dave Cohen’s picture

Status: Active » Needs review

here's what I'm testing as a fix. Haven't noticed bad side effects (yet).


Index: fb.module                                                                                                 
===================================================================
--- fb.module   (revision 2792)                                                                                  
+++ fb.module   (working copy)                                                                                   
@@ -302,9 +302,16 @@
   $params['access_token'] = fb_access_token($fb);                                                               
   $params['api_key'] = $fb->getAppId();                                                                         
   $params['format'] = 'json-strings';                                                                           
+                                                                                                                
+  // Here's how to create a url that conforms to standards:                                                     
   $url = url("https://api.facebook.com/method/{$method}", array(                                                
                'query' => $params,                                                                              
              ));                                                                                                
+  // Facebook does not accept the standard.                                                                     
+  // http://forum.developers.facebook.net/viewtopic.php?id=76228                                                
+  // @TODO - get rid of this urldecode, if facebook ever gets their act together.                               
+  $url = rawurldecode($url);                                                                                    
+                                                                                                                
   $http = drupal_http_request($url);                                                                            
   //dpm($http, $url); // debug                                                                                  
Dave Cohen’s picture

Status: Needs review » Fixed

I no longer think the patch above is necessary. Facebook seems to have fixed the problem.

strae’s picture

I confirm, today it's ok.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

rezvani63’s picture

@Dave Cohen @Strae I'm facing "Invalid OAuth 2.0 Access Token." message. This is when I activate fb_permissions.module. Do you think Facebook again changed it's API? What's th solution?

idot’s picture

same problem when trying to add an app I get "Facebook API exception Invalid OAuth 2.0 Access Token" and

#0 .../sites/all/libraries/facebook-php-sdk/src/facebook.php(490): Facebook->_restserver(Array)
#1 .../sites/all/modules/fb/fb.module(546): Facebook->api(Array)
#2 .../sites/all/modules/fb/contrib/fb_permission.module(186): fb_fql_query()
#3 .../includes/common.inc(2892): fb_permission_form_alter(Object(Facebook), 'SELECT permissi...')
#4 .../includes/form.inc(552): drupal_alter()
#5 .../includes/form.inc(107): drupal_prepare_form(Array, Array, 'fb_app_edit_for...')
#6 .../includes/menu.inc(348): drupal_get_form('fb_permission_f...', Array)
#7 .../index.php(18): menu_execute_active_handler()
#8 {main}

$_REQUEST:
Array
(
[q] => admin/build/fb/fb_app_create
[__utma] => 141730922.2125940019.1286147812.1286147812.1292832903.2
[__utmz] => 141730922.1286147812.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
[__utma_a2a] => 4564551935.1324564110.1293007184.1295871261.1295871674.22
[SESSe5eaadeafc4809b7ac359989a013f335] => e4ceb9b9f335ba3f018ccc0d229508d1
[has_js] => 1
)

REQUEST_URI:
/?q=admin/build/fb/fb_app_create

what cause that error?

cyrilar’s picture

I had the same error, and to resolve it, i had to uncomment the line 544 of fb.module in sites/all/modules/fb/fb.module.
You'll have to comment the two next lines too, like that

function fb_fql_query($fb, $query, $params = array()) {
$params['query'] = $query;
$result = fb_call_method($fb, 'fql.query', $params);
/*$params['method'] = 'fql.query';
$result = $fb->api($params);*/

return $result;
}

Sorry if i got a bad english, i'm french ;)

Dave Cohen’s picture

Assigned: Dave Cohen » Unassigned

I checked in a fix for that. Updating the latest .dev release should help you.

I don't generally look in closed issues for new comments. You should start a new issue when reporting a new problem.

adityagada’s picture

Thanks Cyrilar.

But the function was on line 570.

ranx’s picture

RC7 worked just fine until i enabled the extended permissions module. Now I got the same error as the original poster.

Latest dev version replaced the white screen and long OAuth Access Token error with: "Failed to get extended permissions. Invalid OAuth 2.0 Access Token"

So something still seems to be broken.

Also tried the fix suggested in #19 and got he following error : "warning: fread() [function.fread]: SSL: fatal protocol error in /home/la02/16140509/includes/common.inc on line 552."

Dave Cohen’s picture

With the current .dev build, you should be able to save the application, then return to the edit form and select extended permission.

Facebook doesn't allow a query of the extended permission list until the apikey and secret are known.

rrrob’s picture

I'm using the latest dev build, and I get the same error as poster #22: "Failed to get extended permissions. Invalid OAuth 2.0 Access Token"

I am able to edit the apps settings, but the "Facebook extended permissions" fieldset still says 'Failed to get extended permissions from facebook. Submit this form, then click "edit" to see extended permission options.' even after I save the form and then edit the app again.

Dave Cohen’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new955 bytes

Thanks for pointing that out.

Dave Cohen’s picture

Status: Needs review » Closed (fixed)

Sorry, posted to wrong issue. fb_permission issue is #1045484: Facebook API exception on create app page

forexpivots’s picture

StatusFileSize
new36.17 KB

I have the same problem here.
Also, it's not retrieving the picture in the Forum Posts.
See screenshot.

forexpivots’s picture

Status: Closed (fixed) » Active

Hi guys,
Just following up on this issue.
It seems that this is getting worse.

Now I don't have the User Picture and the Username has vanished too. The content on the post remains alright, but username and picture is gone.
When I go to User Admin, I can see the user there, the e-mail, etc...

Can someone give me a hand...I'd appreciate.

Thanks a bunch, guys!

Dave Cohen’s picture

Status: Active » Closed (won't fix)

Please start a new issue. This is not the same problem as originally reported.

msti’s picture

#19 solved the error for me
Failed to query facebook user info: Invalid OAuth 2.0 Access Token 190. (logged into facebook as )
using rc8