Skip to content

Commit

Permalink
Support Passport 11 (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankurk91 authored Nov 17, 2022
1 parent ae25335 commit 95ebfa1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 27 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
53 changes: 32 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
# 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
```

The package will automatically register itself.

## Configuring

As the first step, you need to implement `SocialUserResolverInterface`:

```php
<?php

Expand Down Expand Up @@ -77,6 +83,7 @@ class AppServiceProvider extends ServiceProvider
You are done!

## Usage

Example of usage with `axios`:

```javascript
Expand All @@ -86,24 +93,24 @@ axios.post('/oauth/token', {
client_secret: clientSecret, // client secret
provider: providerName, // name of provider (e.g., 'facebook', 'google' etc.)
access_token: providerAccessToken, // access token issued by specified provider
})
.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
});
})
.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`:
Expand Down Expand Up @@ -143,16 +150,19 @@ if ($response->getStatusCode() === Response::HTTP_OK) {
```

## Testing

You can run the tests with:

```bash
composer test
```

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

## Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

## Credits
Expand All @@ -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.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 95ebfa1

Please sign in to comment.