|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of the keacefull/wechat. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) xiaomin <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* This source file is subject to the MIT license that is bundled |
|
8
|
|
|
* with this source code in the file LICENSE. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace EasyWeChat\OpenWork\Work\Auth; |
|
12
|
|
|
|
|
13
|
|
|
use EasyWeChat\Kernel\AccessToken as BaseAccessToken; |
|
|
|
|
|
|
14
|
|
|
use EasyWeChat\OpenWork\Application; |
|
15
|
|
|
use Pimple\Container; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Class AccessToken |
|
19
|
|
|
* @package EasyWeChat\OpenWork\Work\Auth |
|
20
|
|
|
*/ |
|
21
|
|
|
class AccessToken extends BaseAccessToken |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @var string |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $requestMethod = 'POST'; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var String 授权方企业ID |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $auth_corpid; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var String 授权方企业永久授权码,通过get_permanent_code获取 |
|
35
|
|
|
*/ |
|
36
|
|
|
protected $permanent_code; |
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
protected $component; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* AccessToken constructor. |
|
43
|
|
|
* @param Container $app |
|
44
|
|
|
* @param String $auth_corpid |
|
45
|
|
|
* @param String $permanent_code |
|
46
|
|
|
* @param Application $component |
|
47
|
|
|
*/ |
|
48
|
|
|
public function __construct(Container $app, String $auth_corpid, String $permanent_code,Application $component) |
|
|
|
|
|
|
49
|
|
|
{ |
|
50
|
|
|
$this->auth_corpid = $auth_corpid; |
|
|
|
|
|
|
51
|
|
|
$this->permanent_code = $permanent_code; |
|
52
|
|
|
parent::__construct($app); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Credential for get token. |
|
57
|
|
|
* |
|
58
|
|
|
* @return array |
|
59
|
|
|
*/ |
|
60
|
|
|
protected function getCredentials(): array |
|
61
|
|
|
{ |
|
62
|
|
|
return [ |
|
63
|
|
|
'auth_corpid' => $this->auth_corpid, |
|
64
|
|
|
'permanent_code' => $this->permanent_code, |
|
65
|
|
|
]; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @return string |
|
70
|
|
|
*/ |
|
71
|
|
|
public function getEndpoint(): string |
|
72
|
|
|
{ |
|
73
|
|
|
return 'cgi-bin/service/get_corp_token?'.http_build_query([ |
|
74
|
|
|
'suite_access_token' => $this->component['suite_access_token']->getToken()['suite_access_token'], |
|
75
|
|
|
]); |
|
76
|
|
|
} |
|
77
|
|
|
} |