From 95ebfa1c1c687e380079af757dfe1e74464e3068 Mon Sep 17 00:00:00 2001 From: Ankur Kumar Date: Thu, 17 Nov 2022 17:11:18 +0530 Subject: [PATCH] Support Passport 11 (#48) --- .github/workflows/tests.yml | 5 ++-- CHANGELOG.md | 2 ++ README.md | 53 ++++++++++++++++++++++--------------- composer.json | 6 ++--- 4 files changed, 39 insertions(+), 27 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 692158c..e2a35fe 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,20 +17,19 @@ jobs: strategy: fail-fast: false matrix: - php: [7.4, 8.0, 8.1] + php: [8.0, 8.1] name: php v${{ matrix.php }} steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv - tools: composer:v2 coverage: pcov - name: Install dependencies diff --git a/CHANGELOG.md b/CHANGELOG.md index b9ee24d..706d67d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,10 @@ All notable changes to `laravel-passport-social-grant` will be documented in this file: ## 3.0.0 + * Drop support for Passport v6.x and v7.x * Bump min php version to 7.2 ## 1.0.0 + - Initial release diff --git a/README.md b/README.md index 784a607..72b88b4 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,22 @@ # Laravel Passport Social Grant [![Packagist](https://badgen.net/packagist/v/coderello/laravel-passport-social-grant)](https://packagist.org/packages/coderello/laravel-passport-social-grant) -[![GitHub tag](https://badgen.net/github/tag/coderello/laravel-passport-social-grant)](https://github.com/coderello/laravel-passport-social-grant/releases) +[![GitHub tag](https://badgen.net/github/tag/coderello/laravel-passport-social-grant)](https://github.com/coderello/laravel-passport-social-grant/tags) [![License](https://badgen.net/packagist/license/coderello/laravel-passport-social-grant)](LICENSE.md) [![Downloads](https://badgen.net/packagist/dt/coderello/laravel-passport-social-grant)](https://packagist.org/packages/coderello/laravel-passport-social-grant/stats) [![tests](https://github.com/coderello/laravel-passport-social-grant/workflows/tests/badge.svg)](https://github.com/coderello/laravel-passport-social-grant/actions) -This package adds a social grant for your OAuth2 server. It can be useful if have an API and want to provide the ability for your users to login/register through social networks. +This package adds a social grant for your OAuth2 server. It can be useful if have an API and want to provide the ability +for your users to login/register through social networks. -As a result you will be able to exchange `access_token`, issued by the OAuth2 server of any social provider, to `access_token` and `refresh_token` issued by your own OAuth2 server. +As a result you will be able to exchange `access_token`, issued by the OAuth2 server of any social provider, +to `access_token` and `refresh_token` issued by your own OAuth2 server. You will receive this `access_token` and return the user instance that corresponds to it on your own. ## Installation + You can install this package via composer using this command: + ```bash composer require coderello/laravel-passport-social-grant ``` @@ -20,7 +24,9 @@ composer require coderello/laravel-passport-social-grant The package will automatically register itself. ## Configuring + As the first step, you need to implement `SocialUserResolverInterface`: + ```php { - const { - access_token: accessToken, - expires_in: expiresIn, - refresh_token: refreshToken, - } = response.data; - - // success logic - }) - .catch((error) => { - const { - message, - hint, - } = error.response.data; - - // error logic - }); +}) + .then((response) => { + const { + access_token: accessToken, + expires_in: expiresIn, + refresh_token: refreshToken, + } = response.data; + + // success logic + }) + .catch((error) => { + const { + message, + hint, + } = error.response.data; + + // error logic + }); ``` Example of usage with `guzzle`: @@ -143,6 +150,7 @@ if ($response->getStatusCode() === Response::HTTP_OK) { ``` ## Testing + You can run the tests with: ```bash @@ -150,9 +158,11 @@ composer test ``` ## Changelog + Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. ## Contributing + Please see [CONTRIBUTING](CONTRIBUTING.md) for details. ## Credits @@ -162,4 +172,5 @@ Created by [Illia Sakovich](https://github.com/hivokas) Maintained by [Ankur Kumar](https://github.com/ankurk91) ## License + The MIT License (MIT). Please see [License File](LICENSE.md) for more information. diff --git a/composer.json b/composer.json index 6aebb2a..7e1c6b5 100644 --- a/composer.json +++ b/composer.json @@ -11,12 +11,12 @@ } ], "require": { - "php": "^7.4||^8.0", - "laravel/passport": "^10.2.2" + "php": "^8.0", + "laravel/passport": "^11.3.0" }, "require-dev": { "mockery/mockery": "^1.4.4", - "orchestra/testbench": "^6.23.2", + "orchestra/testbench": "^7.13.0", "laminas/laminas-diactoros": "^2.8" }, "autoload": {