1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63<?php
/**
* Directus – <http://getdirectus.com>
*
* @link The canonical repository – <https://github.com/directus/directus>
* @copyright Copyright 2006-2017 RANGER Studio, LLC – <http://rangerstudio.com>
* @license GNU General Public License (v3) – <http://www.gnu.org/copyleft/gpl.html>
*/
namespace Directus\Authentication;
use Directus\Application\Application;
use League\OAuth2\Client\Provider\Google;
/**
* Google Social Login provider
*
* @author Welling Guzmán <welling@rngr.org>
*/
class GoogleProvider extends TwoSocialProvider
{
/**
* @var Google
*/
protected $provider = null;
/**
* @inheritDoc
*/
public function getName()
{
return 'google';
}
/**
* @inheritdoc
*/
public function getScopes()
{
return [
'email'
];
}
/**
* Creates the Google provider oAuth client
*
* @return Google
*/
protected function createProvider()
{
$this->provider = new Google([
'clientId' => $this->config->get('client_id'),
'clientSecret' => $this->config->get('client_secret'),
'redirectUri' => $this->getRedirectUrl($this->getName()),
'hostedDomain' => $this->config->get('hosted_domain'),
]);
return $this->provider;
}
}