12 require_once dirname(dirname(__FILE__)) .
'/EOAuth2Service.php';
20 protected $name =
'google_oauth';
21 protected $title =
'Google';
22 protected $type =
'OAuth';
23 protected $jsArguments = array(
'popup' => array(
'width' => 500,
'height' => 450));
25 protected $client_id =
'';
26 protected $client_secret =
'';
27 protected $scope =
'https://www.googleapis.com/auth/userinfo.profile';
28 protected $providerOptions = array(
29 'authorize' =>
'https://accounts.google.com/o/oauth2/auth',
30 'access_token' =>
'https://accounts.google.com/o/oauth2/token',
34 $info = (array)$this->
makeSignedRequest(
'https://www.googleapis.com/oauth2/v1/userinfo');
36 $this->attributes[
'id'] = $info[
'id'];
37 $this->attributes[
'name'] = $info[
'name'];
39 if (!empty($info[
'link']))
40 $this->attributes[
'url'] = $info[
'link'];
55 $this->
setState(
'redirect_uri', $redirect_uri);
57 if (isset($_GET[
'js']))
58 $url .=
'&display=popup';
63 return $this->providerOptions[
'access_token'];
68 'client_id' => $this->client_id,
69 'client_secret' => $this->client_secret,
70 'grant_type' =>
'authorization_code',
72 'redirect_uri' => $this->
getState(
'redirect_uri'),
82 $this->
setState(
'auth_token', $token->access_token);
83 $this->
setState(
'expires', time() + $token->expires_in - 60);
84 $this->access_token = $token->access_token;
94 protected function makeRequest($url, $options = array(), $parseJson =
true) {
95 $options[
'query'][
'alt'] =
'json';
105 if (isset($json->error)) {
107 'code' => $json->error->code,
108 'message' => $json->error->message,