1<?php
2
3use dokuwiki\plugin\oauth\Adapter;
4use dokuwiki\plugin\oauthdoorkeeper\DoorKeeper;
5
6/**
7 * Service Implementation for oAuth Doorkeeper authentication
8 */
9class action_plugin_oauthdoorkeeper extends Adapter
10{
11
12    /** @inheritdoc */
13    public function registerServiceClass()
14    {
15        return DoorKeeper::class;
16    }
17
18    /** * @inheritDoc */
19    public function getUser()
20    {
21        $oauth = $this->getOAuthService();
22        $data = array();
23
24        $url = $this->getConf('baseurl') . '/api/v1/me.json';
25
26
27        $raw = $oauth->request($url);
28        $result = json_decode($raw, true);
29
30        $data['user'] = 'doorkeeper-' . $result['id'];
31        $data['name'] = 'doorkeeper-' . $result['id'];
32        $data['mail'] = $result['email'];
33
34        return $data;
35    }
36
37    /** @inheritDoc */
38    public function getLabel()
39    {
40        return 'Doorkeeper';
41    }
42
43    /** @inheritDoc */
44    public function getColor()
45    {
46        return '#b64145';
47    }
48
49}
50