1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Stevenmaguire\Services\Trello\Traits; |
4
|
|
|
|
5
|
|
|
use League\OAuth1\Client\Credentials\TemporaryCredentials; |
6
|
|
|
|
7
|
|
|
trait AuthorizationTrait |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Retrieves currently configured authorization broker. |
11
|
|
|
* |
12
|
|
|
* @return Stevenmaguire\Services\Trello\Authorization |
|
|
|
|
13
|
|
|
* @codeCoverageIgnore |
14
|
|
|
*/ |
15
|
|
|
abstract public function getAuthorization(); |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Retrieves currently configured http broker. |
19
|
|
|
* |
20
|
|
|
* @return Stevenmaguire\Services\Trello\Http |
|
|
|
|
21
|
|
|
* @codeCoverageIgnore |
22
|
|
|
*/ |
23
|
|
|
abstract public function getHttp(); |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Retrieves http response from Trello api for authorization. |
27
|
|
|
* |
28
|
|
|
* @param array $attributes |
29
|
|
|
* |
30
|
2 |
|
* @return object |
31
|
|
|
*/ |
32
|
2 |
|
public function getAuthorize($attributes = []) |
33
|
|
|
{ |
34
|
|
|
return $this->getHttp()->get('authorize', $attributes); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Retrieves complete authorization url. |
39
|
|
|
* |
40
|
|
|
* @param League\OAuth1\Client\Credentials\TemporaryCredentials $temporaryCredentials |
|
|
|
|
41
|
|
|
* |
42
|
4 |
|
* @return string |
43
|
|
|
*/ |
44
|
4 |
|
public function getAuthorizationUrl(TemporaryCredentials $temporaryCredentials = null) |
45
|
|
|
{ |
46
|
|
|
return $this->getAuthorization()->getAuthorizationUrl($temporaryCredentials); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Retrives access token credentials with token and verifier. |
51
|
|
|
* |
52
|
|
|
* @param string $token |
53
|
|
|
* @param string $verifier |
54
|
|
|
* @param League\OAuth1\Client\Credentials\TemporaryCredentials $temporaryCredentials |
55
|
|
|
* |
56
|
4 |
|
* @return League\OAuth1\Client\Credentials\CredentialsInterface |
|
|
|
|
57
|
|
|
*/ |
58
|
4 |
|
public function getAccessToken($token, $verifier, TemporaryCredentials $temporaryCredentials = null) |
59
|
|
|
{ |
60
|
|
|
return $this->getAuthorization()->getToken($token, $verifier, $temporaryCredentials); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Creates and returns new temporary credentials instance. |
65
|
|
|
* |
66
|
2 |
|
* @return League\OAuth1\Client\Credentials\CredentialsInterface |
67
|
|
|
*/ |
68
|
2 |
|
public function getTemporaryCredentials() |
69
|
|
|
{ |
70
|
|
|
return $this->getAuthorization()->getTemporaryCredentials(); |
71
|
2 |
|
} |
72
|
|
|
} |
73
|
|
|
|