/** * Set facebook token * * @param \Facebook\Authentication\AccessToken $token * * @return Apishka_SocialLogin_Provider_Facebook this */ private function setFacebookToken(\Facebook\Authentication\AccessToken $token) { $this->getStorage()->set($this->getAlias(), 'access_token', $token->getValue())->set($this->getAlias(), 'expiresAt', $token->getExpiresAt())->set($this->getAlias(), 'auth_data', ['access_token' => $token->getValue(), 'expiresAt' => $token->getExpiresAt()]); $this->_facebook_token = $token; return $this; }
/** * Cache the Facebook access token string * @param AccessToken|string $accessToken * @throws FacebookAuthenticationException */ protected function setAccessToken($accessToken) { if ($accessToken && Yii::app()->session) { Yii::app()->session['fb_token'] = (string) $accessToken; } if (is_string($accessToken)) { $accessToken = new AccessToken($accessToken); } if ($accessToken instanceof AccessToken) { if ($accessToken->getExpiresAt()) { Yii::app()->session['fb_token_expires'] = $accessToken->getExpiresAt(); } $this->_token = $accessToken; // this way it will automatically be used by all API requests $this->_fb->setDefaultAccessToken($accessToken); } }