public function saveAccessToken(AccessToken $accessToken)
 {
     $this->deleteAccessToken();
     $accessToken->setUserId($this->getUserId());
     $this->getObjectManager()->persist($accessToken);
     $this->getObjectManager()->flush();
 }
 protected function syncAccessToken(AccessToken $token = null)
 {
     if ($token !== null) {
         $this->accessTokenInstance = $token;
         $_SESSION[$this->accessTokenKey] = array('issueTime' => $token->getIssueTime()->format(DateTime::ATOM), 'accessToken' => $token->getAccessToken());
     } else {
         $tk = $_SESSION[$this->accessTokenKey];
         if ($tk === null) {
             $this->accessTokenInstance = null;
         } elseif ($this->accessTokenInstance === null) {
             $this->accessTokenInstance = new AccessToken(DateTime::createFromFormat(DateTime::ATOM, $tk['issueTime']), $tk['accessToken']);
         }
     }
     return $this->accessTokenInstance;
 }