public function access($code, $options = array()) { if ($code === null) { throw new Exception(array('message' => 'Expected Authorization Code from ' . ucfirst($this->name) . ' is missing')); } return parent::access($code, $options); }
public function callback() { // Load the provider $this->provider = Provider::forge($this->provider, $this->config); if (Input::get('code')) { return $this->provider->access(Input::get('code')); } else { switch (Input::get('error')) { case 'access_denied': throw new CancelException('The resource owner or authorization server denied the request.'); case 'invalid_request': throw new ResponseException('The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.'); case 'unauthorized_client': throw new ResponseException('The client is not authorized to request an authorization code using this method.'); case 'unsupported_response_type': throw new ResponseException('The authorization server does not support obtaining an authorization code using this method.'); case 'invalid_scope': throw new ResponseException('The requested scope is invalid, unknown, or malformed.'); case 'server_error': throw new ResponseException('The authorization server encountered an unexpected condition which prevented it from fulfilling the request.'); case 'temporarily_unavailable': throw new ResponseException('The authorization server is currently unable to handle the request due to a temporary overloading or maintenance of the server.'); } } }
public function callback() { // Load the provider $this->provider = Provider::forge($this->provider, $this->config); $error = Input::get('error'); if (null !== $error) { throw new Auth_Strategy_Exception(ucfirst($this->provider->name) . " Error: " . $error); } $code = Input::get('code'); if (null === $code or empty($code)) { // Send the user back to the beginning throw new Auth_Strategy_Exception('invalid token after coming back to site'); } try { return $this->provider->access($code); } catch (Exception $e) { throw new Auth_Strategy_Exception('That didnt work: ' . $e); } }
public function refresh_token($callback = null) { if (!$this->refresh_token) { throw new \FuelException('The refresh token was not supplied or was empty'); } if (!$this->client_id or !$this->client_secret) { throw new \FuelException('The client_id and client_secret are required to refresh tokens'); } if (!is_callable($this->update_token)) { \Log::debug('update_token wasn\'t correctly set. If you are calling this directly, please ensure $callback contains the logic to store an updated access_token and expiry. Otherwise you must specify it.'); } if (\Package::load('oauth2') === false) { throw new \FuelException('The OAuth2 package is required to refresh tokens'); } $access_token = \OAuth2\Provider::forge('google', array('id' => $this->client_id, 'secret' => $this->client_secret))->access($this->refresh_token, array('grant_type' => 'refresh_token')); $this->access_token = $access_token->access_token; $this->expires = $access_token->expires; /* This prompts the user to store the new token */ //this is called when the if (is_callable($this->update_token)) { call_user_func_array($this->update_token, array($this)); } //this is called when the if (is_callable($callback)) { $callback($this); } return $access_token; }
public function callback() { // Load the provider $this->provider = \OAuth2\Provider::forge($this->provider, $this->config); return $this->provider->access(\Input::get('code')); }
public function access($code, $options = array()) { // Add Api-Key header $options['header'] = 'Api-Key: ' . $this->client_id; return parent::access($code, $options); }