-
Notifications
You must be signed in to change notification settings - Fork 455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Indeed OAuth Provider #1134
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,6 +85,7 @@ parameters: | |
src/IFSP: '[email protected]:SocialiteProviders/IFSP.git' | ||
src/Imgur: '[email protected]:SocialiteProviders/Imgur.git' | ||
src/Imis: '[email protected]:SocialiteProviders/Imis.git' | ||
src/Indeed: '[email protected]:SocialiteProviders/Indeed.git' | ||
src/Instagram: '[email protected]:SocialiteProviders/Instagram.git' | ||
src/InstagramBasic: '[email protected]:SocialiteProviders/InstagramBasic.git' | ||
src/Instructure: '[email protected]:SocialiteProviders/Instructure.git' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace SocialiteProviders\Indeed; | ||
|
||
use SocialiteProviders\Manager\SocialiteWasCalled; | ||
|
||
class IndeedExtendSocialite | ||
{ | ||
/** | ||
* Register the provider. | ||
* | ||
* @param SocialiteWasCalled $socialiteWasCalled | ||
*/ | ||
public function handle(SocialiteWasCalled $socialiteWasCalled): void | ||
{ | ||
$socialiteWasCalled->extendSocialite('indeed', Provider::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace SocialiteProviders\Indeed; | ||
|
||
use GuzzleHttp\RequestOptions; | ||
use SocialiteProviders\Manager\OAuth2\AbstractProvider; | ||
use SocialiteProviders\Manager\OAuth2\User; | ||
|
||
class Provider extends AbstractProvider | ||
{ | ||
public const IDENTIFIER = 'INDEED'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $scopeSeparator = ' '; | ||
|
||
protected $scopes = ['email', 'offline_access']; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function getAuthUrl($state) | ||
{ | ||
return $this->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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
atymic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": "[email protected]" | ||
} | ||
], | ||
"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\\": "" | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need
offline_access
token by default? I assume we can omit this in the providerThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @atymic, I don't know why but they require to have
offline_access
included when requesting foremail
https://docs.indeed.com/dev/docs/authentication-overview#scopes
Here is a screenshot from the above url.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh ok.