Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit 772f1f6

Browse files
committed
:octocat:
1 parent 7b7be95 commit 772f1f6

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

README.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
# Documentation
2727
## Requirements
2828
- 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
3131
- see [`chillerlan/php-oauth`](https://github.com/chillerlan/php-oauth) for already implemented providers
3232

3333
## Getting Started
@@ -37,7 +37,7 @@ use chillerlan\OAuth\Providers\<PROVIDER_NAMESPACE>\<PROVIDER>;
3737
use chillerlan\OAuth\{
3838
OAuthOptions, Storage\SessionTokenStorage
3939
};
40-
use chillerlan\HTTP\CurlClient;
40+
use chillerlan\HTTP\Psr18\CurlClient;
4141

4242
// OAuthOptions
4343
$options = new OAuthOptions([
@@ -47,8 +47,8 @@ $options = new OAuthOptions([
4747
'callbackURL' => '<API_CALLBACK_URL>',
4848

4949
// 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',
5252
]);
5353

5454
// HTTPClientInterface
@@ -135,9 +135,9 @@ $response = $provider->request(
135135
['content-type' => 'whatever']
136136
);
137137

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();
141141
```
142142

143143
## Extensions
@@ -190,37 +190,39 @@ There are 2 different `OAuthStorageInterface`, refer to these for implementation
190190
### [`OAuthInterface`](https://github.com/chillerlan/php-oauth-core/blob/master/src/Core/OAuthProvider.php)
191191
method | return
192192
------ | ------
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`
197199

198200
property | description
199201
-------- | -----------
200202
`$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)
201206
`$userRevokeURL` | an optional link to the provider's user control panel where they can revoke the current token
202207

203208
### [`OAuth1Interface`](https://github.com/chillerlan/php-oauth-core/blob/master/src/Core/OAuth1Provider.php)
204209
method | return
205210
------ | ------
206211
`getAccessToken(string $token, string $verifier, string $tokenSecret = null)` | `AccessToken`
207212
`getRequestToken()` | `AccessToken`
208-
`getSignature(string $url, array $params, string $method = null)` | string
209213

210214
### [`OAuth2Interface`](https://github.com/chillerlan/php-oauth-core/blob/master/src/Core/OAuth2Provider.php)
211215
method | return
212216
------ | ------
213-
`__construct(HTTPClientInterface $http, OAuthStorageInterface $storage, ContainerInterface $options, LoggerInterface $logger = null, array $scopes = null)` | -
214217
`getAccessToken(string $code, string $state = null)` | `AccessToken`
218+
`getAuthURL(array $params = null, $scopes = null)` | PSR-7 `UriInterface`
215219

216220
### `ClientCredentials`
217221
implemented by `OAuth2ClientCredentialsTrait`
218222

219223
method | return
220224
------ | ------
221225
`getClientCredentialsToken(array $scopes = null)` | `AccessToken`
222-
(protected) `getClientCredentialsTokenBody(array $scopes)` | array
223-
(protected) `getClientCredentialsTokenHeaders()` | array
224226

225227
### `CSRFToken`
226228
implemented by `CSRFTokenTrait`
@@ -262,7 +264,6 @@ method | return | description
262264
------ | ------ | -----------
263265
`__construct(array $properties = null)` | - |
264266
`__set(string $property, $value)` | void | overrides `chillerlan\Traits\Container`
265-
`__toArray()` | array | from `chillerlan\Traits\Container`
266267
`setExpiry(int $expires = null)` | `AccessToken` |
267268
`isExpired()` | `bool` |
268269

@@ -275,6 +276,7 @@ property | type | default | allowed | description
275276
`$refreshToken` | string | null | * |
276277
`$extraParams` | array | `[]` | |
277278
`$expires` | int | `AccessToken::EOL_UNKNOWN` | |
279+
`$provider` | string | null | * |
278280

279281
# Disclaimer
280282
OAuth tokens are secrets and should be treated as such. Store them in a safe place,

0 commit comments

Comments
 (0)