I use Laravel 8 (the last version), and I want redirect users to Twitter to log them.
I realized that there was this display also on previous versions of Laravel.
I use this line code:
return redirect()->away($url);
// or
return redirect($url);
Why, when I use this lines code to login user with Twitter, I've this display on page between login page and Twitter login page ?
use Abraham\TwitterOAuth\TwitterOAuth;
public function login(Request $request): string
{
$connection = new TwitterOAuth(
config('services.twitter.client_id'),
config('services.twitter.client_secret')
);
$requestToken = $connection->oauth('oauth/request_token', [
'oauth_callback' => config('services.twitter.redirect'),
]);
$request->session()->put('oauth_token', $requestToken['oauth_token']);
$request->session()->put('oauth_token_secret', $requestToken['oauth_token_secret']);
$url = $connection->url('oauth/authorize', [
'oauth_token' => $requestToken['oauth_token'],
]);
return redirect()->away($url);
}
The redirection is visible, and ugly.

Incorrect return value is declared for your login function, you should change return type string to RedirectResponse (Alternative, you can remove type declarations altogether)
public function login(Request $request): string
to:
public function login(Request $request): \Illuminate\Http\RedirectResponse
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With