質問編集履歴
2
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
テストテストテストテスト
|
test
CHANGED
@@ -1,179 +1 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
User作成後にPassportでのアクセストークンを返却すること
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
### 参考ページ
|
8
|
-
|
9
|
-
https://codeday.me/jp/qa/20190402/535184.html
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
### 発生している問題・エラーメッセージ
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
```
|
18
|
-
|
19
|
-
{
|
20
|
-
|
21
|
-
"error": "unsupported_grant_type",
|
22
|
-
|
23
|
-
"error_description": "The authorization grant type is not supported by the authorization server.",
|
24
|
-
|
25
|
-
"hint": "Check that all required parameters have been provided",
|
26
|
-
|
27
|
-
"message": "The authorization grant type is not supported by the authorization server."
|
28
|
-
|
29
|
-
}
|
30
|
-
|
31
|
-
```
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
### 該当のソースコード
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
```ここに言語名を入力
|
40
|
-
|
41
|
-
<?php
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
namespace App\Http\Controllers;
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
use App\Http\Requests\UserRequest;
|
50
|
-
|
51
|
-
use App\User;
|
52
|
-
|
53
|
-
use Illuminate\Support\Facades\Hash;
|
54
|
-
|
55
|
-
use Laravel\Passport\Client;
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
class UserController extends Controller
|
60
|
-
|
61
|
-
{
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
/**
|
66
|
-
|
67
|
-
* Create a new user instance after a valid registration.
|
68
|
-
|
69
|
-
*
|
70
|
-
|
71
|
-
* @param array $data
|
72
|
-
|
73
|
-
* @return \App\User
|
74
|
-
|
75
|
-
*/
|
76
|
-
|
77
|
-
protected function create(UserRequest $request)
|
78
|
-
|
79
|
-
{
|
80
|
-
|
81
|
-
User::create([
|
82
|
-
|
83
|
-
'name' => $request->name,
|
84
|
-
|
85
|
-
'email' => $request->email,
|
86
|
-
|
87
|
-
'password' => Hash::make($request->password),
|
88
|
-
|
89
|
-
]);
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
// And created user until here.
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
$client = Client::where('password_client', 1)->first();
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
// Is this $request the same request? I mean Request $request? Then wouldn't it mess the other $request stuff? Also how did you pass it on the $request in $proxy? Wouldn't Request::create() just create a new thing?
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
// Fire off the internal request.
|
106
|
-
|
107
|
-
$token = $request::create(
|
108
|
-
|
109
|
-
'oauth/token',
|
110
|
-
|
111
|
-
'POST',
|
112
|
-
|
113
|
-
[
|
114
|
-
|
115
|
-
'grant_type' => 'password',
|
116
|
-
|
117
|
-
'client_id' => $client->id,
|
118
|
-
|
119
|
-
'client_secret' => $client->secret,
|
120
|
-
|
121
|
-
'username' => $request->email,
|
122
|
-
|
123
|
-
'password' => Hash::make($request->password),
|
124
|
-
|
125
|
-
'scope' => '[*]',
|
126
|
-
|
127
|
-
]
|
128
|
-
|
129
|
-
);
|
130
|
-
|
131
|
-
return \Route::dispatch($token);
|
132
|
-
|
133
|
-
}
|
134
|
-
|
135
|
-
}
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
```
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
### 試したこと 下記のソースでも同様でした。
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
```
|
148
|
-
|
149
|
-
$params =
|
150
|
-
|
151
|
-
[
|
152
|
-
|
153
|
-
'grant_type' => 'password',
|
154
|
-
|
155
|
-
'client_id' => $client->id,
|
156
|
-
|
157
|
-
'client_secret' => $client->secret,
|
158
|
-
|
159
|
-
'username' => $request->email,
|
160
|
-
|
161
|
-
'password' => Hash::make($request->password),
|
162
|
-
|
163
|
-
'scope' => '*',
|
164
|
-
|
165
|
-
];
|
166
|
-
|
167
|
-
$request->request->add($params);
|
168
|
-
|
169
|
-
$proxy = $request::create('oauth/token', 'POST');
|
170
|
-
|
171
|
-
return Route::dispatch($proxy);
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
```
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
ご教授お願いいたします。
|
1
|
+
テストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテスト
|
1
ああ
test
CHANGED
File without changes
|
test
CHANGED
@@ -140,93 +140,35 @@
|
|
140
140
|
|
141
141
|
|
142
142
|
|
143
|
-
### 試したこと
|
143
|
+
### 試したこと 下記のソースでも同様でした。
|
144
144
|
|
145
145
|
|
146
146
|
|
147
147
|
```
|
148
148
|
|
149
|
-
$
|
149
|
+
$params =
|
150
150
|
|
151
|
-
|
151
|
+
[
|
152
152
|
|
153
|
+
'grant_type' => 'password',
|
153
154
|
|
155
|
+
'client_id' => $client->id,
|
154
156
|
|
155
|
-
|
157
|
+
'client_secret' => $client->secret,
|
156
158
|
|
159
|
+
'username' => $request->email,
|
157
160
|
|
161
|
+
'password' => Hash::make($request->password),
|
158
162
|
|
159
|
-
|
163
|
+
'scope' => '*',
|
160
164
|
|
165
|
+
];
|
161
166
|
|
167
|
+
$request->request->add($params);
|
162
168
|
|
163
|
-
$r
|
169
|
+
$proxy = $request::create('oauth/token', 'POST');
|
164
170
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
$postdata = array(
|
170
|
-
|
171
|
-
"grant_type" => "authorization_code",
|
172
|
-
|
173
|
-
"code" => $code,
|
174
|
-
|
175
|
-
"redirect_uri" => $redirect_uri
|
176
|
-
|
177
|
-
);
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
$header = array(
|
184
|
-
|
185
|
-
'Authorization: Basic '.$basicAuth,
|
186
|
-
|
187
|
-
'Content-Type: application/x-www-form-urlencoded; charset=utf-8'
|
188
|
-
|
189
|
-
);
|
190
|
-
|
191
|
-
$ch = curl_init($api);
|
192
|
-
|
193
|
-
curl_setopt_array($ch, array(
|
194
|
-
|
195
|
-
CURLOPT_HEADER => true,
|
196
|
-
|
197
|
-
CURLOPT_HTTPHEADER => $header,
|
198
|
-
|
199
|
-
CURLOPT_POST => true,
|
200
|
-
|
201
|
-
CURLOPT_POSTFIELDS => $postdata,
|
202
|
-
|
203
|
-
CURLOPT_RETURNTRANSFER => true,
|
204
|
-
|
205
|
-
CURLOPT_SSL_VERIFYPEER => false
|
206
|
-
|
207
|
-
));
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
171
|
+
return Route::dispatch($proxy);
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
// HTTPステータスコードをチェックしエラーならエラー内容を出力
|
216
|
-
|
217
|
-
if(curl_errno($ch)) {
|
218
|
-
|
219
|
-
echo 'Curl error: ' . curl_error($ch);
|
220
|
-
|
221
|
-
}
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
curl_close($ch);
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
echo $result;
|
230
172
|
|
231
173
|
|
232
174
|
|