From a417913be9abdbc214ef1543d9812acad8bd11b6 Mon Sep 17 00:00:00 2001 From: smiley Date: Sun, 19 May 2024 22:14:22 +0200 Subject: [PATCH] :book: --- README.md | 10 ++++++++++ docs/Development/Additional-functionality.md | 15 ++++++++++++--- docs/Usage/Using-examples.md | 7 ++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d51baa2..97a6009 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/Development/Additional-functionality.md b/docs/Development/Additional-functionality.md index 8b7f5cd..d70adfc 100644 --- a/docs/Development/Additional-functionality.md +++ b/docs/Development/Additional-functionality.md @@ -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) @@ -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, @@ -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){ diff --git a/docs/Usage/Using-examples.md b/docs/Usage/Using-examples.md index afb1f97..5a9ae21 100644 --- a/docs/Usage/Using-examples.md +++ b/docs/Usage/Using-examples.md @@ -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