/** * This action issues access and refresh tokens and is called only * by the 3rd party. All output should be JSON. * * You DO NOT need to extend/replace this action. */ public function action_token() { $this->response->headers('Content-Type', File::mime_by_ext('json')); try { // Attempt to issue a token $this->response->body($this->_oauth->token()); } catch (OAuth2_Exception $e) { // Something went wrong, lets give a formatted error $this->response->status(400); $this->response->body($e->getJsonError()); } }
public function access($code, $options = array()) { if ($code === null) { throw new OAuth2_Exception('Expected Authorization Code from ' . ucfirst($this->name) . ' is missing'); } return parent::access($code, $options); }
public function __construct(array $options = array()) { if (empty($options['scope'])) { $options['scope'] = array('r_basicprofile', 'r_emailaddress'); } // Array it if its string $options['scope'] = (array) $options['scope']; parent::__construct($options); }
public function before() { parent::before(); // Load the cookie session $this->session = Session::instance('cookie'); // Get the name of the demo from the class name $provider = strtolower($this->api); // Load the provider $this->provider = OAuth2_Provider::factory($provider); // Load the client $this->client = OAuth2_Client::factory(Kohana::config("oauth.{$provider}")); if ($token = $this->session->get($this->key('access'))) { // Make the access token available $this->token = $token; } }
public function __construct(array $options = array()) { empty($options['scope']) and $options['scope'] = 'basic'; $options['scope'] = (array) $options['scope']; parent::__construct($options); }
protected function _oauth_verify_token($scope = NULL) { list($client_id, $user_id) = $this->_oauth->verify_token($scope); $this->_oauth_client_id = $client_id; $this->_oauth_user_id = $user_id; }
/** * @param $name Provider name * @param array Provider options * @return OAuth2_Provider */ public function provider($name, array $options = NULL) { return OAuth2_Provider::factory($name, $options); }