Laravel Socialite:缺少必需参数:redirect_uri

时间:2016-12-08 16:36:19

标签: php laravel-5 laravel-socialite

我正在使用Laravel 5.3和Socialite。

我收到400 Bad Request错误消息:

Missing required parameter: redirect_uri

它生成的网址是:

https://accounts.google.com/o/oauth2/auth?scope=openid+profile+email&response_type=code&state=RYPmT1B93CaUdi44Z7iwfmRPx3hIy7an7yxAVY9l

以下详细信息:

service.php

'google' => [
        'client_id' => '1234455-u3ifk8tr1qs41487fmevg2h2s1v6ubue.apps.googleusercontent.com',
        'client_secret' => 'DxSOS0p1xKNuPger3IS_E4-i',
        'redirect' => 'http://localhost:8000/google/callback',
    ],

路线

Route::get('/{provider}/redirect', 'Auth\RegisterController@redirectToProvider');
Route::get('/{provider}/callback', 'Auth\RegisterController@handleProviderCallback');

Google控制台中的授权URI设置

http://localhost:8000/google/callback

控制器

public function handleProviderCallback($provider)
    {
        try {
            $social_user = Socialite::driver($provider)->user();

        } catch (Exception $e) {
            return redirect('/');
        }
}

0 个答案:

没有答案