Yii Framework Forum: yii-facebook-opengraph and access token - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

yii-facebook-opengraph and access token Rate Topic: -----

#1 User is offline   Narretz 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 48
  • Joined: 20-August 11

Posted 15 April 2012 - 05:16 PM

Hello,

I have a curious problem with the aforementioned extension. Whenever I log in with facebook, and come to the specified redirection page, I have no access token in the session and the usual techniques of checking fb auth fail, e.g. the Login Link is displayed instead of the logout link (I have code and state in the url). When I refresh the page or go to another page, I have the access token, and am considered logged in. I have extracted the following error message: Code_was_invalid_or_expired__The_session_is_invalid_because_the_user_logged_out.
This happens in the function getAccessTokenfromCode. However, this message is thrown internally whenever FB is checking if there is an auth user. I guess something is out of sync, or comes too late, but I wonder what?

The code is very simple, hence why I am really puzzled:

Yii::app()->facebook->getAccessToken();

	$user = Yii::app()->facebook->getUser();

	if ($user) {
	  try {
	    // Proceed knowing you have a logged in user who's authenticated.
	    $user_profile = Yii::app()->facebook->api('/me');
	  } catch (FacebookApiException $e) {
	  	//throw $e;
	    $user = null;
	  }
	}

// Login or logout url will be needed depending on current user state.
if ($user) {
  $logout_url = Yii::app()->facebook->getLogoutUrl();
  echo CHtml::link('Log out from Facebook', $logout_url); 
} else {
  $login_url = Yii::app()->facebook->getLoginUrl();
  echo CHtml::link('Log in with Facebook', $login_url); 
}


0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users