'Laravel Socialite user always null
i work on a project and i need to use google oauth2.0 but It's always send a null user. I installed a new laravel 8.5 project to be sure and it's always the same situationeven if i use github or facebook instead of google.
My environment config :
OS: Parrot Ara (Debian Bullseye)
PHP version : 8.0
Laravel version : 8.5
in routes/web.php
Route::get("connexion/google/redirect", function(){
return Socialite::driver('google')->redirect();
})->name("google.redirect");
Route::get("connexion/google/callback", function(){
dd(Socialite::driver('google'));
});
in config/services.php
'google' => [
'client_id' => env('GOOGLE_CLIENT_ID'),
'client_secret' => env('GOOGLE_CLIENT_SECRET'),
'redirect' => env('GOOGLE_REDIRECT_URI'),
],
'github' => [
'client_id' => env('GITHUB_CLIENT_ID'),
'client_secret' => env('GITHUB_CLIENT_SECRET'),
'redirect' => env('GITHUB_REDIRECT_URI'),
],
'facebook' => [
'client_id' => env('FACEBOOK_CLIENT_ID'),
'client_secret' => env('FACEBOOK_CLIENT_SECRET'),
'redirect' => env('FACEBOOK_REDIRECT_URI'),
],
the return of dd(Socialite::driver('google')); (i remove client secret and id)
Laravel\Socialite\Two\GoogleProvider {#294 ▼
#scopeSeparator: " "
#scopes: array:3 [▶]
#request: Illuminate\Http\Request {#43 ▶}
#httpClient: null
#clientId: "xxxxxxxxxxxxxxxxxxxxxxxxx"
#clientSecret: "xxxxxxxxxxxxxxxxxxxx"
#redirectUrl: "http://localhost:8000/connexion/google/callback"
#parameters: []
#encodingType: 1
#stateless: false
#usesPKCE: false
#guzzle: []
#user: null
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
