26
26
# Documentation
27
27
## Requirements
28
28
- PHP 7.2+
29
- - the [ Sodium] ( http://php.net/manual/book.sodium.php ) extension for token encryption
30
- - cURL, PHP's stream wrapper or a HTTP client library of your choice
29
+ - the [ Sodium] ( http://php.net/manual/book.sodium.php ) extension for token encryption
30
+ - a [ PSR-18 ] ( https://www.php-fig.org/psr/psr-18/ ) compatible HTTP client library of your choice
31
31
- see [ ` chillerlan/php-oauth ` ] ( https://github.com/chillerlan/php-oauth ) for already implemented providers
32
32
33
33
## Getting Started
@@ -37,7 +37,7 @@ use chillerlan\OAuth\Providers\<PROVIDER_NAMESPACE>\<PROVIDER>;
37
37
use chillerlan\OAuth\{
38
38
OAuthOptions, Storage\SessionTokenStorage
39
39
};
40
- use chillerlan\HTTP\CurlClient;
40
+ use chillerlan\HTTP\Psr18\ CurlClient;
41
41
42
42
// OAuthOptions
43
43
$options = new OAuthOptions([
@@ -47,8 +47,8 @@ $options = new OAuthOptions([
47
47
'callbackURL' => '<API _CALLBACK_URL >',
48
48
49
49
// HTTPOptions
50
- 'ca_info' => '/path/to/cacert.pem', // https://curl.haxx.se/ca/cacert.pem
51
- 'userAgent' => 'my-awesome-oauth-app',
50
+ 'ca_info' => '/path/to/cacert.pem', // https://curl.haxx.se/ca/cacert.pem
51
+ 'userAgent' => 'my-awesome-oauth-app',
52
52
]);
53
53
54
54
// HTTPClientInterface
@@ -135,9 +135,9 @@ $response = $provider->request(
135
135
['content-type' => 'whatever']
136
136
);
137
137
138
- // use the data
139
- $headers = $response->headers ;
140
- $data = $response->json ;
138
+ // use the data: $response is a PSR-7 ResponseInterface
139
+ $headers = $response->getHeaders() ;
140
+ $data = $response->getBody()->getContents() ;
141
141
```
142
142
143
143
## Extensions
@@ -190,37 +190,39 @@ There are 2 different `OAuthStorageInterface`, refer to these for implementation
190
190
### [ ` OAuthInterface ` ] ( https://github.com/chillerlan/php-oauth-core/blob/master/src/Core/OAuthProvider.php )
191
191
method | return
192
192
------ | ------
193
- ` __construct(HTTPClientInterface $http, OAuthStorageInterface $storage, ContainerInterface $options, LoggerInterface $logger = null) ` | -
194
- ` getAuthURL(array $params = null) ` | string
195
- ` getStorageInterface() ` | ` OAuthStorageInterface `
196
- ` request(string $path, array $params = null, string $method = null, $body = null, array $headers = null) ` | ` HTTPResponseInterface `
193
+ ` __construct(ClientInterface $http, OAuthStorageInterface $storage, SettingsContainerInterface $options) ` | -
194
+ ` getAuthURL(array $params = null) ` | PSR-7 ` UriInterface `
195
+ ` request(string $path, array $params = null, string $method = null, $body = null, array $headers = null) ` | PSR-7 ` ResponseInterface `
196
+ ` setRequestFactory(RequestFactoryInterface $requestFactory) ` | ` OAuthInterface `
197
+ ` setStreamFactory(StreamFactoryInterface $streamFactory) ` | ` OAuthInterface `
198
+ ` setUriFactory(UriFactoryInterface $uriFactory) ` | ` OAuthInterface `
197
199
198
200
property | description
199
201
-------- | -----------
200
202
` $serviceName ` | the classname for the current provider
203
+ ` $accessTokenURL ` | the provider`s access token URL
204
+ ` $authURL ` | the provider`s authentication token URL
205
+ ` $revokeURL ` | an optional URL to revoke an access token (via API)
201
206
` $userRevokeURL ` | an optional link to the provider's user control panel where they can revoke the current token
202
207
203
208
### [ ` OAuth1Interface ` ] ( https://github.com/chillerlan/php-oauth-core/blob/master/src/Core/OAuth1Provider.php )
204
209
method | return
205
210
------ | ------
206
211
` getAccessToken(string $token, string $verifier, string $tokenSecret = null) ` | ` AccessToken `
207
212
` getRequestToken() ` | ` AccessToken `
208
- ` getSignature(string $url, array $params, string $method = null) ` | string
209
213
210
214
### [ ` OAuth2Interface ` ] ( https://github.com/chillerlan/php-oauth-core/blob/master/src/Core/OAuth2Provider.php )
211
215
method | return
212
216
------ | ------
213
- ` __construct(HTTPClientInterface $http, OAuthStorageInterface $storage, ContainerInterface $options, LoggerInterface $logger = null, array $scopes = null) ` | -
214
217
` getAccessToken(string $code, string $state = null) ` | ` AccessToken `
218
+ ` getAuthURL(array $params = null, $scopes = null) ` | PSR-7 ` UriInterface `
215
219
216
220
### ` ClientCredentials `
217
221
implemented by ` OAuth2ClientCredentialsTrait `
218
222
219
223
method | return
220
224
------ | ------
221
225
` getClientCredentialsToken(array $scopes = null) ` | ` AccessToken `
222
- (protected) ` getClientCredentialsTokenBody(array $scopes) ` | array
223
- (protected) ` getClientCredentialsTokenHeaders() ` | array
224
226
225
227
### ` CSRFToken `
226
228
implemented by ` CSRFTokenTrait `
@@ -262,7 +264,6 @@ method | return | description
262
264
------ | ------ | -----------
263
265
` __construct(array $properties = null) ` | - |
264
266
` __set(string $property, $value) ` | void | overrides ` chillerlan\Traits\Container `
265
- ` __toArray() ` | array | from ` chillerlan\Traits\Container `
266
267
` setExpiry(int $expires = null) ` | ` AccessToken ` |
267
268
` isExpired() ` | ` bool ` |
268
269
@@ -275,6 +276,7 @@ property | type | default | allowed | description
275
276
` $refreshToken ` | string | null | * |
276
277
` $extraParams ` | array | ` [] ` | |
277
278
` $expires ` | int | ` AccessToken::EOL_UNKNOWN ` | |
279
+ ` $provider ` | string | null | * |
278
280
279
281
# Disclaimer
280
282
OAuth tokens are secrets and should be treated as such. Store them in a safe place,
0 commit comments