Passed
Push — master ( 5621d4...3d9624 )
by mingyoung
02:21
created

SsoClient::user()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the mingyoung/dingtalk.
5
 *
6
 * (c) 张铭阳 <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace EasyDingTalk\Auth;
13
14
use EasyDingTalk\Kernel\Http\Client;
15
16
class SsoClient extends Client
17
{
18
    /**
19
     * 获取应用后台免登 AccessToken
20
     *
21
     * @return mixed
22
     */
23
    public function getToken()
24
    {
25
        return $this->get('sso/gettoken', [
26
            'corpid' => $this->app['config']->get('corp_id'),
27
            'corpsecret' => $this->app['config']->get('sso_secret'),
28
        ]);
29
    }
30
31
    /**
32
     * 获取用户身份信息
33
     *
34
     * @return mixed
35
     */
36
    public function user()
37
    {
38
        return $this->get('sso/getuserinfo', [
39
            'access_token' => $this->getToken()['access_token'],
40
            'code' => $this->app['request']->get('code'),
41
        ]);
42
    }
43
}
44