質問編集履歴
2
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -65,6 +65,17 @@
|
|
65
65
|
);
|
66
66
|
}
|
67
67
|
```
|
68
|
+
|
69
|
+
|
70
|
+
config/services.php
|
71
|
+
```
|
72
|
+
'google' => [
|
73
|
+
'client_id' => env('**********************************************************'),
|
74
|
+
'client_secret' => env('*************************'),
|
75
|
+
'redirect' => env('**************************'),
|
76
|
+
],
|
77
|
+
```
|
78
|
+
|
68
79
|
config/app.php
|
69
80
|
```
|
70
81
|
'providers' => [
|
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -5,16 +5,17 @@
|
|
5
5
|
Socialite 4.1.0
|
6
6
|
|
7
7
|
でOAuth認証を実装しようと考え、下記サイトを参考にしました。
|
8
|
-
|
8
|
+
```
|
9
9
|
https://leben.mobi/blog/laravel5_social_login/php/
|
10
|
-
|
10
|
+
```
|
11
11
|
一通りサイトに習いコードを記述しましたが、ソーシャルボタンを押下時に下記エラーが発生します。
|
12
|
-
|
12
|
+
```
|
13
13
|
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_RECOVERABLE_ERROR)
|
14
14
|
Argument 1 passed to Laravel\Socialite\SocialiteManager::formatRedirectUrl() must be of the type array, null given, called in C:\xampp\htdocs\demo\vendor\laravel\socialite\src\SocialiteManager.php on line 126
|
15
|
-
|
15
|
+
```
|
16
16
|
エラー箇所は下記のようです。
|
17
17
|
C:\xampp\htdocs\demo\vendor\laravel\socialite\src\SocialiteManager.php
|
18
|
+
```
|
18
19
|
*
|
19
20
|
* @param array $config
|
20
21
|
* @return array
|
@@ -48,6 +49,123 @@
|
|
48
49
|
*
|
49
50
|
* @throws \InvalidArgumentException
|
50
51
|
*
|
52
|
+
```
|
53
|
+
原因がわからず困っております。
|
54
|
+
ご教授よろしくお願いします。
|
51
55
|
|
56
|
+
追記:
|
57
|
+
SocialiteManager.php 126行付近
|
58
|
+
```
|
59
|
+
public function buildProvider($provider, $config)
|
60
|
+
{
|
61
|
+
return new $provider(
|
62
|
+
$this->app['request'], $config['client_id'],
|
63
|
+
$config['client_secret'], $this->formatRedirectUrl($config),
|
64
|
+
Arr::get($config, 'guzzle', [])
|
65
|
+
);
|
66
|
+
}
|
67
|
+
```
|
52
|
-
|
68
|
+
config/app.php
|
69
|
+
```
|
70
|
+
'providers' => [
|
71
|
+
Laravel\Socialite\SocialiteServiceProvider::class,
|
72
|
+
],
|
73
|
+
'aliases' => [
|
74
|
+
'Socialite' => Laravel\Socialite\Facades\Socialite::class,
|
75
|
+
],
|
76
|
+
```
|
77
|
+
|
78
|
+
Auth/LoginController.php
|
79
|
+
```
|
80
|
+
<?php
|
81
|
+
|
82
|
+
namespace App\Http\Controllers\Auth;
|
83
|
+
|
84
|
+
use Illuminate\Http\Request;
|
85
|
+
use App\Http\Controllers\Controller;
|
86
|
+
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
87
|
+
use App\Events\Logined;
|
53
|
-
|
88
|
+
use Socialite;
|
89
|
+
use App\User;
|
90
|
+
use Auth;
|
91
|
+
|
92
|
+
|
93
|
+
class LoginController extends Controller
|
94
|
+
{
|
95
|
+
/*
|
96
|
+
|--------------------------------------------------------------------------
|
97
|
+
| Login Controller
|
98
|
+
|--------------------------------------------------------------------------
|
99
|
+
|
|
100
|
+
| This controller handles authenticating users for the application and
|
101
|
+
| redirecting them to your home screen. The controller uses a trait
|
102
|
+
| to conveniently provide its functionality to your applications.
|
103
|
+
|
|
104
|
+
*/
|
105
|
+
|
106
|
+
use AuthenticatesUsers;
|
107
|
+
protected $maxAttempts = 2; // ログイン試行回数(回)
|
108
|
+
protected $decayMinutes = 10; // ログインロックタイム(分)
|
109
|
+
/**
|
110
|
+
* Where to redirect users after login.
|
111
|
+
*
|
112
|
+
* @var string
|
113
|
+
*/
|
114
|
+
protected $redirectTo = '/verified';
|
115
|
+
|
116
|
+
/**
|
117
|
+
* Create a new controller instance.
|
118
|
+
*
|
119
|
+
* @return void
|
120
|
+
*/
|
121
|
+
public function __construct()
|
122
|
+
{
|
123
|
+
$this->middleware('guest')->except('logout');
|
124
|
+
}
|
125
|
+
|
126
|
+
/**
|
127
|
+
* ログイン認証後の処理
|
128
|
+
* @param Request $request
|
129
|
+
* @param $user
|
130
|
+
*/
|
131
|
+
protected function authenticated(Request $request, $user)
|
132
|
+
{
|
133
|
+
// ログインイベントを発火させ最終ログイン日時を記録する
|
134
|
+
event(new Logined());
|
135
|
+
}
|
136
|
+
|
137
|
+
public function username()
|
138
|
+
{
|
139
|
+
return 'userid';
|
140
|
+
}
|
141
|
+
|
142
|
+
/**
|
143
|
+
* Handle Social login request
|
144
|
+
*
|
145
|
+
* @return response
|
146
|
+
*/
|
147
|
+
|
148
|
+
public function socialLogin($social)
|
149
|
+
{
|
150
|
+
return Socialite::driver($social)->redirect();
|
151
|
+
}
|
152
|
+
|
153
|
+
/**
|
154
|
+
* Obtain the user information from Social Logged in.
|
155
|
+
* @param $social
|
156
|
+
* @return Response
|
157
|
+
*/
|
158
|
+
|
159
|
+
public function handleProviderCallback($social)
|
160
|
+
{
|
161
|
+
$userSocial = Socialite::driver($social)->user();
|
162
|
+
$user = User::where(['email' => $userSocial->getEmail()])->first();
|
163
|
+
if($user){
|
164
|
+
Auth::login($user);
|
165
|
+
return redirect()->action('HomeController@index');
|
166
|
+
}else{
|
167
|
+
return view('auth.register',['name' => $userSocial->getName(), 'email' => $userSocial->getEmail()]);
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}
|
171
|
+
```
|