-
Notifications
You must be signed in to change notification settings - Fork 939
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e177bf
commit 6e66b22
Showing
2 changed files
with
53 additions
and
0 deletions.
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
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,38 @@ | ||
<?php | ||
|
||
namespace Laravel\Socialite\Two; | ||
|
||
use GuzzleHttp\RequestOptions; | ||
use Illuminate\Support\Arr; | ||
|
||
class XProvider extends TwitterProvider | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getAuthUrl($state) | ||
{ | ||
return $this->buildAuthUrlFromBase('https://x.com/i/oauth2/authorize', $state); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getTokenUrl() | ||
{ | ||
return 'https://api.x.com/2/oauth2/token'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getUserByToken($token) | ||
{ | ||
$response = $this->getHttpClient()->get('https://api.x.com/2/users/me', [ | ||
RequestOptions::HEADERS => ['Authorization' => 'Bearer '.$token], | ||
RequestOptions::QUERY => ['user.fields' => 'profile_image_url'], | ||
]); | ||
|
||
return Arr::get(json_decode($response->getBody(), true), 'data'); | ||
} | ||
} |