10 defined(
'JPATH_PLATFORM') or die;
11 jimport('joomla.oauth.v2client');
38 $this->options = isset($options) ? $options :
new JRegistry;
39 $this->client = isset($client) ? $client :
new JOAuth2Client($this->options);
49 public function authenticate()
53 return $this->client->authenticate();
63 public function isAuthenticated()
65 return $this->client->isAuthenticated();
80 public function query($url, $data = null, $headers = null, $method =
'get')
84 return $this->client->query($url, $data, $headers, $method);
94 protected function googlize()
96 if (!$this->client->getOption(
'authurl'))
98 $this->client->setOption(
'authurl',
'https://accounts.google.com/o/oauth2/auth');
100 if (!$this->client->getOption(
'tokenurl'))
102 $this->client->setOption(
'tokenurl',
'https://accounts.google.com/o/oauth2/token');
104 if (!$this->client->getOption(
'requestparams'))
106 $this->client->setOption(
'requestparams', Array());
109 $params = $this->client->getOption(
'requestparams');
111 if (!array_key_exists(
'access_type', $params))
113 $params[
'access_type'] =
'offline';
115 if ($params[
'access_type'] ==
'offline' && $this->client->getOption(
'userefresh') === null)
117 $this->client->setOption(
'userefresh',
true);
119 if (!array_key_exists(
'approval_prompt', $params))
121 $params[
'approval_prompt'] =
'auto';
124 $this->client->setOption(
'requestparams', $params);
126 return $this->client;