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

Commit 9613688

Browse files
committed
:octocat:
1 parent ef7cdbc commit 9613688

File tree

1 file changed

+37
-7
lines changed

1 file changed

+37
-7
lines changed

README.md

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,55 +54,83 @@ and offers basic methods that are common to the OAuth 1/2 interfaces, all suppli
5454
method | return | description
5555
------ | ------ | -----------
5656
`__construct(ClientInterface $http, OAuthStorageInterface $storage, SettingsContainerInterface $options, LoggerInterface $logger = null)` | - |
57+
`__call(string $name, array $arguments)` | PSR-7 `ResponseInterface` | magic API
5758
`getAuthURL(array $params = null)` | PSR-7 `UriInterface` |
5859
`request(string $path, array $params = null, string $method = null, $body = null, array $headers = null)` | PSR-7 `ResponseInterface` |
60+
`setStorage(OAuthStorageInterface $storage)` | `OAuthInterface` |
61+
`setLogger(LoggerInterface $logger)` | void | PSR-3
5962
`setRequestFactory(RequestFactoryInterface $requestFactory)` | `OAuthInterface` | PSR-17
6063
`setStreamFactory(StreamFactoryInterface $streamFactory)` | `OAuthInterface` | PSR-17
6164
`setUriFactory(UriFactoryInterface $uriFactory)` | `OAuthInterface` | PSR-17
6265
`getRequestAuthorization(RequestInterface $request, AccessToken $token)` | PSR-7 `RequestInterface`
6366

67+
The following public properties are available:
68+
6469
property | description
6570
-------- | -----------
6671
`$serviceName` | the classname for the current provider
67-
`$accessTokenURL` | the provider`s access token URL
68-
`$authURL` | the provider`s authentication token URL
6972
`$revokeURL` | an optional URL to revoke an access token (via API)
7073
`$userRevokeURL` | an optional link to the provider's user control panel where they can revoke the current token
7174
`$apiDocs` | a link to the provider's API docs
7275
`$applicationURL` | a link to the API/application credential generation page
7376
`$endpoints` | an `EndpointMapInterface` for the current provider
7477

78+
The following internal (protected) properties affect a provider's functionality
79+
80+
property | description
81+
-------- | -----------
82+
`$authURL` | URL to the the provider's consent screen
83+
`$accessTokenURL` | the provider's token excahnge URL
84+
`$apiURL` | the base URL of the provider's API to access
85+
`$endpointMap` | (optional) a class FQCN of an `EndpointMapInterface` for the provider's API
86+
`$authHeaders` | (optional) additional headers to use during authentication
87+
`$apiHeaders` | (optional) additional headers to use during API access
88+
89+
7590
### [`OAuth1Interface`](https://github.com/chillerlan/php-oauth-core/blob/master/src/Core/OAuth1Provider.php)
76-
extends `OAuthInterface`
7791

7892
method | return
7993
------ | ------
8094
`getRequestToken()` | `AccessToken`
8195
`getAccessToken(string $token, string $verifier)` | `AccessToken`
8296

97+
Protected properties:
98+
99+
property | description
100+
-------- | -----------
101+
`$requestTokenURL` | the OAuth1 request token excange URL
102+
83103
#### A minimal OAuth1 provider
84104
```php
85105
use chillerlan\OAuth\Core\OAuth1Provider;
86106

87107
class MyOauth1Provider extends Oauth1Provider{
88108

89-
protected $apiURL = 'https://api.example.com';
90109
protected $requestTokenURL = 'https://example.com/oauth/request_token';
91110
protected $authURL = 'https://example.com/oauth/authorize';
92111
protected $accessTokenURL = 'https://example.com/oauth/access_token';
112+
protected $apiURL = 'https://api.example.com';
93113

94114
}
95115
```
96116

97117

98118
### [`OAuth2Interface`](https://github.com/chillerlan/php-oauth-core/blob/master/src/Core/OAuth2Provider.php)
99-
extends `OAuthInterface`
100119

101120
method | return
102121
------ | ------
103122
`getAccessToken(string $code, string $state = null)` | `AccessToken`
104123
`getAuthURL(array $params = null, $scopes = null)` | PSR-7 `UriInterface`
105124

125+
Protected properties:
126+
127+
property | description
128+
-------- | -----------
129+
`$authMethod` | the authentication method, one of `OAuth2Interface::AUTH_METHODS_HEADER` or `OAuth2Interface::AUTH_METHODS_QUERY`
130+
`$scopesDelimiter` | (optional) a delimiter string for the OAuth2 scopes, defaults to `' '` (space)
131+
`$refreshTokenURL` | (optional) a refresh token exchange URL, in case it differs from `$accessTokenURL`
132+
`$clientCredentialsTokenURL` | (optional) a client credentials token exchange URL, in case it differs from `$accessTokenURL`
133+
106134
#### `ClientCredentials`
107135
The `ClientCredentials` interface indicates that the provider supports the [client credentials grant type](https://tools.ietf.org/html/rfc6749#section-4.4).
108136

@@ -132,16 +160,18 @@ use chillerlan\OAuth\Core\OAuth2Provider;
132160

133161
class MyOauth2Provider extends Oauth2Provider implements ClientCredentials, CSRFToken, TokenRefresh{
134162

135-
protected $apiURL = 'https://api.example.com';
136163
protected $authURL = 'https://example.com/oauth2/authorize';
137164
protected $accessTokenURL = 'https://example.com/oauth2/token';
165+
protected $apiURL = 'https://api.example.com';
166+
167+
// optional
138168
protected $clientCredentialsTokenURL = 'https://example.com/oauth2/client_credentials';
139169
protected $authMethod = self::HEADER_BEARER;
140170
protected $scopesDelimiter = ',';
141-
142171
}
143172
```
144173

174+
145175
### [`OAuthStorageInterface`](https://github.com/chillerlan/php-oauth-core/blob/master/src/Storage/OAuthStorageAbstract.php)
146176

147177
The `OAuthStorageInterface` serves for storing access tokens and auth states (CSRF) on a per-user basis.

0 commit comments

Comments
 (0)