Answer the question
In order to leave comments, you need to log in
Laravel Socialite: why does VK say redirect_url is not the same?
I use Laravel Socialite and the provider for VK to it. My code:
Routing:
Route::get('vk', '[email protected]');
Route::get('vk/callback', '[email protected]');
use SocialiteProviders\Manager\Config;
public function vk()
{
$clientId = env('VKONTAKTE_KEY');
$clientSecret = env('VKONTAKTE_SECRET');
$redirectUrl = url('drivers/login/vk/callback');
$config = new Config($clientId, $clientSecret, $redirectUrl);
return \Socialite::with('vkontakte')
->setConfig($config)
->setScopes([])
->redirect();
}
public function vkCallback()
{
$user = \Socialite::driver('vkontakte')->user();
dd($user);
}
Client error: `POST https://oauth.vk.com/access_token` resulted in a `401 Unauthorized` response:
{"error":"invalid_grant","error_description":"redirect_uri is invalid, please pass same redirect_uri, you used in author (truncated...)
Answer the question
In order to leave comments, you need to log in
->setConfig($config) - the answer lies here. For some reason, the config is not pulled dynamically, but is still taken from the one set in config/services.php
The only option I came up with is to change the config itself:
Config::set([$this->service_key => ['client_id' => $ this->app_id, 'client_secret' => $this->app_key, 'redirect' => $this->redirect]]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question