3
3
namespace kamermans \OAuth2 ;
4
4
5
5
use GuzzleHttp \Exception \BadResponseException ;
6
- use kamermans \OAuth2 \GrantType \GrantTypeInterface ;
7
- use kamermans \OAuth2 \Utils \Helper ;
8
6
9
7
/**
10
8
* OAuth2 plugin.
@@ -16,43 +14,43 @@ class OAuth2Handler
16
14
/**
17
15
* The grant type implementation used to acquire access tokens.
18
16
*
19
- * @var GrantTypeInterface
17
+ * @var GrantType\ GrantTypeInterface
20
18
*/
21
19
protected $ grantType ;
22
20
23
21
/**
24
22
* The grant type implementation used to refresh access tokens.
25
23
*
26
- * @var GrantTypeInterface
24
+ * @var GrantType\ GrantTypeInterface
27
25
*/
28
26
protected $ refreshTokenGrantType ;
29
27
30
28
/**
31
29
* The service in charge of including client credentials into requests.
32
30
* to get an access token.
33
31
*
34
- * @var AccessTokenSigner
32
+ * @var Signer\ClientCredentials\SignerInterface
35
33
*/
36
34
protected $ clientCredentialsSigner ;
37
35
38
36
/**
39
37
* The service in charge of including the access token into requests.
40
38
*
41
- * @var AccessTokenSigner
39
+ * @var Signer\AccessToken\SignerInterface
42
40
*/
43
41
protected $ accessTokenSigner ;
44
42
45
43
/**
46
44
* The object including access token.
47
45
*
48
- * @var TokenInterface
46
+ * @var Token\ TokenInterface
49
47
*/
50
48
protected $ rawToken ;
51
49
52
50
/**
53
51
* The service in charge of persisting access token.
54
52
*
55
- * @var TokenPersistenceInterface
53
+ * @var Persistence\ TokenPersistenceInterface
56
54
*/
57
55
protected $ tokenPersistence ;
58
56
@@ -65,8 +63,17 @@ class OAuth2Handler
65
63
protected $ newTokenSupplier ;
66
64
67
65
/**
68
- * @param GrantTypeInterface $grantType
69
- * @param GrantTypeInterface $refreshTokenGrantType
66
+ * Factory responsible for parsing server token response
67
+ *
68
+ * @var callable
69
+ */
70
+ protected $ tokenFactory ;
71
+
72
+ /**
73
+ * @param GrantType\GrantTypeInterface $grantType
74
+ * @param GrantType\GrantTypeInterface|null $refreshTokenGrantType
75
+ * @param Signer\ClientCredentials\SignerInterface|null $clientCredentialsSigner
76
+ * @param Signer\AccessToken\SignerInterface|null $accessTokenSigner
70
77
*/
71
78
public function __construct (
72
79
GrantType \GrantTypeInterface $ grantType ,
@@ -94,6 +101,8 @@ public function __construct(
94
101
95
102
/**
96
103
* @param Signer\ClientCredentials\SignerInterface $signer
104
+ *
105
+ * @return self
97
106
*/
98
107
public function setClientCredentialsSigner (Signer \ClientCredentials \SignerInterface $ signer )
99
108
{
@@ -103,7 +112,9 @@ public function setClientCredentialsSigner(Signer\ClientCredentials\SignerInterf
103
112
}
104
113
105
114
/**
106
- * @param AccessToken\SignerInterface $signer
115
+ * @param Signer\AccessToken\SignerInterface $signer
116
+ *
117
+ * @return self
107
118
*/
108
119
public function setAccessTokenSigner (Signer \AccessToken \SignerInterface $ signer )
109
120
{
@@ -114,6 +125,8 @@ public function setAccessTokenSigner(Signer\AccessToken\SignerInterface $signer)
114
125
115
126
/**
116
127
* @param Persistence\TokenPersistenceInterface $tokenPersistence
128
+ *
129
+ * @return self
117
130
*/
118
131
public function setTokenPersistence (Persistence \TokenPersistenceInterface $ tokenPersistence )
119
132
{
@@ -124,6 +137,8 @@ public function setTokenPersistence(Persistence\TokenPersistenceInterface $token
124
137
125
138
/**
126
139
* @param callable $tokenFactory
140
+ *
141
+ * @return self
127
142
*/
128
143
public function setTokenFactory (callable $ tokenFactory )
129
144
{
@@ -146,7 +161,9 @@ public function setNewTokenSupplier(callable $tokenSupplier) {
146
161
/**
147
162
* Manually set the access token.
148
163
*
149
- * @param string|array|TokenInterface $token An array of token data, an access token string, or a TokenInterface object
164
+ * @param string|array|Token\TokenInterface $token An array of token data, an access token string, or a TokenInterface object
165
+ *
166
+ * @return self
150
167
*/
151
168
public function setAccessToken ($ token )
152
169
{
@@ -179,7 +196,7 @@ public function deleteAccessToken()
179
196
*
180
197
* @return string|null A valid access token or null if unable to get one
181
198
*
182
- * @throws AccessTokenRequestException while trying to run `requestNewAccessToken` method
199
+ * @throws Exception\ AccessTokenRequestException while trying to run `requestNewAccessToken` method
183
200
*/
184
201
public function getAccessToken ()
185
202
{
@@ -207,7 +224,7 @@ public function getAccessToken()
207
224
/**
208
225
* Gets the current Token object
209
226
*
210
- * @return Token\RawToken |null
227
+ * @return Token\TokenInterface |null
211
228
*/
212
229
public function getRawToken ()
213
230
{
@@ -228,7 +245,7 @@ protected function signRequest($request)
228
245
/**
229
246
* Helper method for (callable)tokenFactory
230
247
*
231
- * @return TokenInterface
248
+ * @return Token\ TokenInterface
232
249
*/
233
250
protected function tokenFactory ()
234
251
{
@@ -238,9 +255,7 @@ protected function tokenFactory()
238
255
/**
239
256
* Acquire a new access token from the server.
240
257
*
241
- * @return TokenInterface|null
242
- *
243
- * @throws AccessTokenRequestException
258
+ * @throws Exception\AccessTokenRequestException
244
259
*/
245
260
protected function requestNewAccessToken ()
246
261
{
0 commit comments