我尝试使用postman登录。当将用户名和密码发布到localhost / api / login时,我收到此错误消息。
{
"error": "invalid_credentials",
"message": "The user credentials were incorrect."
}
我的LoginController
private $client;
public function __construct(){
$this->client = Client::find(1);
}
public function login(Request $request){
$this->validate($request, [
'username' => 'required',
'password' => 'required'
]);
return $this->issueToken($request, 'password');
}
我的issueToken方法。
public function issueToken(Request $request, $grantType, $scope = ""){
$params = [
'grant_type' => $grantType,
'client_id' => $this->client->id,
'client_secret' => $this->client->secret,
'scope' => $scope
];
if($grantType !== 'social'){
$params['username'] = $request->username ?: $request->email;
}
$request->request->add($params);
$proxy = Request::create('oauth/token', 'POST');
return Route::dispatch($proxy);
}
我的注册事件很好。所以我的错误是什么?
答案 0 :(得分:0)
检查是否有效
if($grantType !== 'social'){
$params['username'] = $request->username ?: $request->email;
$params['password'] = $request->password; //Send password too ?
}