-
Notifications
You must be signed in to change notification settings - Fork 2
/
action.php
52 lines (42 loc) · 1.07 KB
/
action.php
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
<?php
use dokuwiki\plugin\oauthgoogle\Google;
/**
* Service Implementation for oAuth Google authentication
*/
class action_plugin_oauthgoogle extends \dokuwiki\plugin\oauth\Adapter
{
/**
* We use our own, modified version of the Google service
* @inheritdoc
*/
public function registerServiceClass()
{
return Google::class;
}
/** * @inheritDoc */
public function getUser()
{
$oauth = $this->getOAuthService();
$data = array();
$result = json_decode($oauth->request('https://www.googleapis.com/oauth2/v1/userinfo'), true);
$data['user'] = $result['name'];
$data['name'] = $result['name'];
$data['mail'] = $result['email'];
return $data;
}
/** @inheritDoc */
public function getScopes()
{
return [Google::SCOPE_USERINFO_EMAIL, Google::SCOPE_USERINFO_PROFILE];
}
/** @inheritDoc */
public function getLabel()
{
return 'Google';
}
/** @inheritDoc */
public function getColor()
{
return '#4285F4';
}
}