Skip to content

Commit

Permalink
📖
Browse files Browse the repository at this point in the history
  • Loading branch information
codemasher committed May 19, 2024
1 parent 5edfc91 commit a417913
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ composer require chillerlan/php-oauth
Note: replace `dev-main` with a [version constraint](https://getcomposer.org/doc/articles/versions.md#writing-version-constraints), e.g. `^1.0` - see [releases](https://github.com/chillerlan/php-oauth/releases) for valid versions.


## Examples

There is [the suite of get-token examples](https://php-oauth.readthedocs.io/en/main/Usage/Using-examples.html),
which is mostly intended for development, and there are self-contained examples for a quickstart:

- [OAuth1 example](https://github.com/chillerlan/php-oauth/tree/main/examples/example-oauth1.php)
- [OAuth2 example](https://github.com/chillerlan/php-oauth/tree/main/examples/example-oauth2.php)



# Implemented Providers

<!-- TABLE-START -->
Expand Down
15 changes: 12 additions & 3 deletions docs/Development/Additional-functionality.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,10 @@ class MyOAuth2Provider extends OAuth2Provider implements TokenInvalidate{
* ...
*/

protected function sendTokenInvalidateRequest(string $url, array $body){
protected function sendTokenInvalidateRequest(
string $url,
array $body,
):ResponseInterface{

$request = $this->requestFactory
->createRequest('POST', $url)
Expand All @@ -298,7 +301,10 @@ class MyOAuth2Provider extends OAuth2Provider implements TokenInvalidate{
return $this->http->sendRequest($request);
}

protected function getInvalidateAccessTokenBodyParams(AccessToken $token, string $type):array{
protected function getInvalidateAccessTokenBodyParams(
AccessToken $token,
string $type,
):array{
return [
// here, client_id and client_secret are set additionally
'client_id' => $this->options->key,
Expand All @@ -322,7 +328,10 @@ class MyOAuth2Provider extends OAuth2Provider implements TokenInvalidate{
* ...
*/

public function invalidateAccessToken(AccessToken|null $token = null, string|null $type = null):bool{
public function invalidateAccessToken(
AccessToken|null $token = null,
string|null $type = null,
):bool{

// a token was given
if($token !== null){
Expand Down
7 changes: 6 additions & 1 deletion docs/Usage/Using-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

OAuth is not exactly trivial, and so is live testing an OAuth flow to make sure the implementation and all its details work as expected.
The examples - specifically [the get-token examples](https://github.com/chillerlan/php-oauth/tree/main/examples/get-token) -
are abstracted and condensed as far as possible to make using them as convenient as it can get.
are abstracted and condensed to make using them as convenient as possible.

There are also 2 self-contained, fully working examples to illustrate the whole implementation without any overhead:

- [OAuth1 example](https://github.com/chillerlan/php-oauth/tree/main/examples/example-oauth1.php)
- [OAuth2 example](https://github.com/chillerlan/php-oauth/tree/main/examples/example-oauth2.php)


## Requirements
Expand Down

0 comments on commit a417913

Please sign in to comment.