config = \Zend_Registry::get('config'); if(empty($db)) { $this->db = \Zend_Registry::get('db'); }else{ $this->db = $db; } if(empty($auth)) { $this->auth = \Zend_Auth::getInstance(); if($this->auth->hasIdentity()) { $this->user = $this->auth->getIdentity(); } }else{ $this->auth = false; } } public function bootstrap() { $dsn = "pgsql:dbname={$this->config->db->params->dbname};host={$this->config->db->params->host}"; $storage = new \OAuth2\Storage\Pdo(array('dsn' => $dsn, 'username' => $this->config->db->params->username, 'password' => $this->config->db->params->password)); $server = new \OAuth2\Server($storage); $server->addGrantType(new \OAuth2\GrantType\ClientCredentials($storage)); $server->addGrantType(new \OAuth2\GrantType\AuthorizationCode($storage)); //εΊ”η”¨ζŽˆζƒ //$server->handleTokenRequest(OAuth2\Request::createFromGlobals())->send(); return $server; } }