Пример #1
0
 /**
  * Implements OAuth2::setAccessToken().
  */
 protected function setAccessToken($oauth_token, $client_id, $expires, $scope = NULL)
 {
     $consumer = Doctrine::getTable('sfOauthServerConsumer')->findOneByConsumerKey($client_id);
     if (!$consumer) {
         throw new OAuthException('Invalid Request');
     }
     $authtoken = new sfOauthServerAccessToken();
     $authtoken->setToken($oauth_token);
     $authtoken->setConsumer($consumer);
     $authtoken->setExpires($expires);
     $authtoken->setUserId($this->user_id);
     $authtoken->setScope($this->scope);
     $authtoken->setProtocole(2);
     $authtoken->save();
 }
Пример #2
0
 function new_access_token($token, $consumer, $verifier = null)
 {
     $c = Doctrine::getTable('sfOauthServerConsumer')->findOneByConsumerKey($consumer->key);
     $token = Doctrine::getTable('sfOauthServerRequestToken')->findOneByToken($token->key);
     $key = md5(time());
     $secret = time() + time();
     $accesstoken = new OAuthToken($key, md5(md5($secret)));
     $accesstoken = new sfOauthServerAccessToken();
     $accesstoken->setToken($key);
     $accesstoken->setSecret(md5(md5($secret)));
     $accesstoken->setConsumer($c);
     $accesstoken->setUserId($token->getUserId());
     $accesstoken->setScope($token->getScope());
     $accesstoken->save();
     $accesstoken = new OAuthToken($accesstoken->getToken(), $accesstoken->getSecret());
     return $accesstoken;
 }