diff --git a/IndeedExtendSocialite.php b/IndeedExtendSocialite.php new file mode 100644 index 0000000..bc35a6c --- /dev/null +++ b/IndeedExtendSocialite.php @@ -0,0 +1,18 @@ +extendSocialite('indeed', Provider::class); + } +} diff --git a/Provider.php b/Provider.php new file mode 100644 index 0000000..38d9bd7 --- /dev/null +++ b/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/README.md b/README.md new file mode 100644 index 0000000..aaab5d2 --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ +# 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(); +``` + +### 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 diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..8fd0435 --- /dev/null +++ b/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\\": "" + } + } +}