1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace League\OAuth1\Client\Server; |
4
|
|
|
|
5
|
|
|
use League\OAuth1\Client\Credentials\TokenCredentials; |
6
|
|
|
use Psr\Http\Message\ResponseInterface; |
7
|
|
|
|
8
|
|
|
class Trello extends AbstractServer |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Requested token expiration |
12
|
|
|
* |
13
|
|
|
* @var string |
14
|
|
|
*/ |
15
|
|
|
protected $expiration; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Application name displayed to authenticating user |
19
|
|
|
* |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
protected $name; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Requested token scope |
26
|
|
|
* |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
protected $scope; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Build authorization query parameters. |
33
|
|
|
* |
34
|
|
|
* @param array $options |
35
|
|
|
* |
36
|
|
|
* @return string |
37
|
|
|
*/ |
38
|
4 |
|
protected function buildAuthorizationQueryParameters(array $options = array()) |
39
|
|
|
{ |
40
|
|
|
$params = array( |
41
|
4 |
|
'response_type' => 'fragment', |
42
|
4 |
|
'scope' => isset($options['scope']) ? $options['scope'] : $this->scope, |
43
|
4 |
|
'expiration' => isset($options['expiration']) ? $options['expiration'] : $this->expiration, |
44
|
4 |
|
'name' => isset($options['name']) ? $options['name'] : $this->name, |
45
|
4 |
|
); |
46
|
|
|
|
47
|
4 |
|
return http_build_query(array_filter($params)); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Checks a provider response for errors. |
52
|
|
|
* |
53
|
|
|
* @param ResponseInterface $response |
54
|
|
|
* @param array|string $data Parsed response data |
55
|
|
|
* |
56
|
|
|
* @return void |
57
|
|
|
* @throws IdentityProviderException |
58
|
|
|
*/ |
59
|
2 |
|
protected function checkResponse(ResponseInterface $response, $data) |
60
|
|
|
{ |
61
|
|
|
// |
62
|
2 |
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Generates a resource owner object from a successful resource owner |
66
|
|
|
* details request. |
67
|
|
|
* |
68
|
|
|
* @param array $response |
69
|
|
|
* @param TokenCredentials $tokenCredentials |
70
|
|
|
* |
71
|
|
|
* @return ResourceOwnerInterface |
72
|
|
|
*/ |
73
|
2 |
|
protected function createResourceOwner(array $response, TokenCredentials $tokenCredentials) |
74
|
|
|
{ |
75
|
2 |
|
return new TrelloResourceOwner($response); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Creates an authenticated query string and merges with a given query string, |
80
|
|
|
* if provided. |
81
|
|
|
* |
82
|
|
|
* @param TokenCredentials $tokenCredentials |
83
|
|
|
* @param string $query |
84
|
|
|
* |
85
|
|
|
* @return string |
86
|
|
|
*/ |
87
|
4 |
|
protected function getAuthenticatedQueryString(TokenCredentials $tokenCredentials, $query = '') |
88
|
|
|
{ |
89
|
4 |
|
$query = parse_str($query); |
|
|
|
|
90
|
4 |
|
$query['key'] = (string) $this->clientCredentials; |
91
|
4 |
|
$query['token'] = (string) $tokenCredentials; |
92
|
|
|
|
93
|
4 |
|
return http_build_query($query); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Creates a new authenticated request. |
98
|
|
|
* |
99
|
|
|
* @param string $method |
100
|
|
|
* @param string $url |
101
|
|
|
* @param TokenCredentials $tokenCredentials |
102
|
|
|
* |
103
|
|
|
* @return \GuzzleHttp\Psr7\Request |
104
|
|
|
*/ |
105
|
2 |
|
public function getAuthenticatedRequest($method, $url, TokenCredentials $tokenCredentials) |
106
|
|
|
{ |
107
|
2 |
|
$request = parent::getAuthenticatedRequest($method, $url, $tokenCredentials); |
108
|
|
|
|
109
|
2 |
|
$uri = $request->getUri()->withQuery( |
110
|
2 |
|
$this->getAuthenticatedQueryString( |
111
|
2 |
|
$tokenCredentials, |
112
|
2 |
|
$request->getUri()->getQuery() |
113
|
2 |
|
) |
114
|
2 |
|
); |
115
|
|
|
|
116
|
2 |
|
return $request->withUri($uri); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Gets the URL for redirecting the resource owner to authorize the client. |
121
|
|
|
* |
122
|
|
|
* @return string |
123
|
|
|
*/ |
124
|
4 |
|
protected function getBaseAuthorizationUrl(array $options = array()) |
125
|
|
|
{ |
126
|
|
|
return 'https://trello.com/1/OAuthAuthorizeToken?'. |
127
|
4 |
|
$this->buildAuthorizationQueryParameters($options); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Gets the URL for retrieving temporary credentials. |
132
|
|
|
* |
133
|
|
|
* @return string |
134
|
|
|
*/ |
135
|
2 |
|
protected function getBaseTemporaryCredentialsUrl() |
136
|
|
|
{ |
137
|
2 |
|
return 'https://trello.com/1/OAuthGetRequestToken'; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Gets the URL retrieving token credentials. |
142
|
|
|
* |
143
|
|
|
* @return string |
144
|
|
|
*/ |
145
|
2 |
|
protected function getBaseTokenCredentialsUrl() |
146
|
|
|
{ |
147
|
2 |
|
return 'https://trello.com/1/OAuthGetAccessToken'; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Gets the URL for retrieving user details. |
152
|
|
|
* |
153
|
|
|
* @return string |
154
|
|
|
*/ |
155
|
2 |
|
protected function getResourceOwnerDetailsUrl(TokenCredentials $tokenCredentials) |
156
|
|
|
{ |
157
|
2 |
|
return 'https://api.trello.com/1/members/me?'.$this->getAuthenticatedQueryString($tokenCredentials); |
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.