【发布时间】:2015-06-03 10:04:13
【问题描述】:
我正在使用 Laravel 5 和 jwt-auth 包来处理 JWT。如果用户来自 Facebook,我如何进行身份验证?
我的想法是,我将使用 FB ID 和电子邮件进行身份验证。我通过将密码更改为 fb_id 来做到这一点,不幸的是它没有用。任何建议,为什么我会收到以下错误?谢谢!
验证码:
//facebook
if(Input::has('fb_id')){
$credentials = Input::only('email','fb_id');
}else{
$credentials = Input::only('email', 'password');
}
try {
// attempt to verify the credentials and create a token for the user
if (! $token = JWTAuth::attempt($credentials)) {
return Response::json(['error' => 'invalid_credentials'], 401);
}
} catch (JWTException $e) {
// something went wrong whilst attempting to encode the token
return Response::json(['error' => 'could_not_create_token'], 500);
}
错误:
ErrorException in EloquentUserProvider.php line 108:
Undefined index: password
【问题讨论】:
-
你能为 EloquentUserProvider.php 提供 pastebin 吗?看来您正在使用 $password,但未定义变量。
-
@ChainList 是的,我没有提供密码参数,因为用户来自 facebook。所以我只有 fb_id 和电子邮件来验证用户身份。
标签: php facebook authentication laravel-5 jwt