Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mep's avatar
Level 1

Laravel Socialite Twitter

Does anyone know how can I get the access token and scerect token of a twitter user ? the steps I did are as follows:

  • Add the redirection keys and url in config/services.php
  • Create the path to start session with X(twitter)
Route::get('/twitter', function () { return Socialite::driver('Twitter')->scopes(['tweet.read', 'tweet.write', 'users.read'])->redirect();});
  • Create the path for the callback with a function
Route::get('/twitter/callback',[SocialController::class,'digestToken']);
  • In the callback function what I do is dd($user) to see what properties the user object has.
public function digestToken(Request $request){
        $user = Socialite::driver('Twitter')->user();
        dd($user);
    }

And I don't see the secret user access I can only get the access token and I need both the access token and the secret access token. I have tried many alternatives but none of them work, does anyone have any idea how I could get the tokens?

0 likes
0 replies

Please or to participate in this conversation.