From 5f68ff323088d3af445cd84ddb2d9132b753321e Mon Sep 17 00:00:00 2001 From: sahapranta Date: Wed, 27 Dec 2023 10:32:24 +0600 Subject: [PATCH 1/2] Add Indeed OAuth Provider --- monorepo-builder.yml | 1 + src/Indeed/IndeedExtendSocialite.php | 18 +++++++++ src/Indeed/Provider.php | 57 ++++++++++++++++++++++++++++ src/Indeed/README.md | 42 ++++++++++++++++++++ src/Indeed/composer.json | 33 ++++++++++++++++ 5 files changed, 151 insertions(+) create mode 100644 src/Indeed/IndeedExtendSocialite.php create mode 100644 src/Indeed/Provider.php create mode 100644 src/Indeed/README.md create mode 100644 src/Indeed/composer.json diff --git a/monorepo-builder.yml b/monorepo-builder.yml index a073a2c88..ed0c08110 100644 --- a/monorepo-builder.yml +++ b/monorepo-builder.yml @@ -85,6 +85,7 @@ parameters: src/IFSP: 'git@github.com:SocialiteProviders/IFSP.git' src/Imgur: 'git@github.com:SocialiteProviders/Imgur.git' src/Imis: 'git@github.com:SocialiteProviders/Imis.git' + src/Indeed: 'git@github.com:SocialiteProviders/Indeed.git' src/Instagram: 'git@github.com:SocialiteProviders/Instagram.git' src/InstagramBasic: 'git@github.com:SocialiteProviders/InstagramBasic.git' src/Instructure: 'git@github.com:SocialiteProviders/Instructure.git' diff --git a/src/Indeed/IndeedExtendSocialite.php b/src/Indeed/IndeedExtendSocialite.php new file mode 100644 index 000000000..bc35a6cb0 --- /dev/null +++ b/src/Indeed/IndeedExtendSocialite.php @@ -0,0 +1,18 @@ +extendSocialite('indeed', Provider::class); + } +} diff --git a/src/Indeed/Provider.php b/src/Indeed/Provider.php new file mode 100644 index 000000000..38d9bd750 --- /dev/null +++ b/src/Indeed/Provider.php @@ -0,0 +1,57 @@ +buildAuthUrlFromBase('https://secure.indeed.com/oauth/v2/authorize', $state); + } + + /** + * @inheritDoc + */ + protected function getTokenUrl() + { + return "https://apis.indeed.com/oauth/v2/tokens"; + } + + /** + * @inheritDoc + */ + protected function getUserByToken($token) + { + $response = $this->getHttpClient()->get('https://secure.indeed.com/v2/api/userinfo', [ + RequestOptions::HEADERS => [ + 'Authorization' => 'Bearer ' . $token, + ], + ]); + + return json_decode($response->getBody(), true); + } + + /** + * @inheritDoc + */ + protected function mapUserToObject(array $user) + { + return (new User())->setRaw($user); + } +} diff --git a/src/Indeed/README.md b/src/Indeed/README.md new file mode 100644 index 000000000..eb36de05d --- /dev/null +++ b/src/Indeed/README.md @@ -0,0 +1,42 @@ +# Discord + +```bash +composer require socialiteproviders/indeed +``` + +## Installation & Basic Usage + +Please see the [Base Installation Guide](https://socialiteproviders.com/usage/), then follow the provider specific instructions below. + +### Add configuration to `config/services.php` + +```php +'indeed' => [ + 'client_id' => env('INDEED_CLIENT_ID'), + 'client_secret' => env('INDEED_CLIENT_SECRET'), + 'redirect' => env('INDEED_REDIRECT_URI'), +], +``` + +### Add provider event listener + +Configure the package's listener to listen for `SocialiteWasCalled` events. + +Add the event to your `listen[]` array in `app/Providers/EventServiceProvider`. See the [Base Installation Guide](https://socialiteproviders.com/usage/) for detailed instructions. + +```php +protected $listen = [ + \SocialiteProviders\Manager\SocialiteWasCalled::class => [ + // ... other providers + \SocialiteProviders\Indeed\IndeedExtendSocialite::class.'@handle', + ], +]; +``` + +### Usage + +You should now be able to use the provider like you would regularly use Socialite (assuming you have the facade installed): + +```php +return Socialite::driver('indeed')->redirect(); +``` diff --git a/src/Indeed/composer.json b/src/Indeed/composer.json new file mode 100644 index 000000000..8fd043595 --- /dev/null +++ b/src/Indeed/composer.json @@ -0,0 +1,33 @@ +{ + "name": "socialiteproviders/indeed", + "description": "Indeed OAuth2 Provider for Laravel Socialite", + "license": "MIT", + "keywords": [ + "indeed", + "laravel", + "oauth", + "provider", + "socialite" + ], + "authors": [ + { + "name": "Pranta Saha", + "email": "pranta1204@gmail.com" + } + ], + "support": { + "issues": "https://github.com/socialiteproviders/providers/issues", + "source": "https://github.com/socialiteproviders/providers", + "docs": "https://socialiteproviders.com/indeed" + }, + "require": { + "php": "^8.0", + "ext-json": "*", + "socialiteproviders/manager": "^4.4" + }, + "autoload": { + "psr-4": { + "SocialiteProviders\\Indeed\\": "" + } + } +} From 0ac9aa27a76205a48c32b017a0e6d8e3adb13d34 Mon Sep 17 00:00:00 2001 From: sahapranta Date: Fri, 26 Jan 2024 21:50:38 +0600 Subject: [PATCH 2/2] chore: update doc with return user fields --- src/Indeed/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Indeed/README.md b/src/Indeed/README.md index eb36de05d..aaab5d219 100644 --- a/src/Indeed/README.md +++ b/src/Indeed/README.md @@ -40,3 +40,9 @@ You should now be able to use the provider like you would regularly use Socialit ```php return Socialite::driver('indeed')->redirect(); ``` + +### Returned User fields + +- ``sub`` (**string**) Unique identifier for the user's account. e.g. `248289761001` +- ``email`` (**string**) User's email address. +- ``email_verified`` (**boolean**) Indicates whether the user has verified their email address. e.g. `true` \ No newline at end of file