Answer the question
In order to leave comments, you need to log in
Laravel Socialite: Why is access_token not being stored?
Hello,
I am Laravel Socialite Providers
using Вконтакте
.
access_token
, but if I reload the page, I get an error:Client error: `POST https://oauth.vk.com/access_token` resulted in a `401 Unauthorized` response: {"error":"invalid_grant","error_description":"Code is invalid or expired."}
Route::get('intermediate-path', function(){
$user = Socialite::driver('vkontakte')->user();
$user_check = User::where('vk_id', '=', $user->id)->first();
if ($user_check === null) {
DB::insert('insert into users (vk_id, name, email) values (?, ?, ?)', [
$user->id, $user->name, $user->email
]);
echo "created";
} else {
echo "logged in";
}
});
'vkontakte' => [
clientId = env('VKONTAKTE_KEY');
clientSecret = env('VKONTAKTE_SECRET');
redirectUrl = 'http://localhost:8000/api/auth/intermediate-path';
],
Answer the question
In order to leave comments, you need to log in
Because the token is one-time. You must remember not him, but the user who enters.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question