Когда речь идет о доступе мой логин У меня есть эта ошибка:Войти терпят неудачу в Laravel 5 (JTW)
{"error":"token_not_provided"}
есть в моей .htaccess:
RewriteEngine On
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
У меня есть в моих маршрутах. PHP:
Route::post('/api/login', '[email protected]');
Route::get('/api/login', '[email protected]');
и у меня AuthenticateController:
use JWTAuth;
use Tymon\JWTAuth\Exceptions\JWTException;
class AuthenticateController extends Controller
{
public function authenticate(Request $request)
{
// grab credentials from the request
$credentials = $request->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);
}
// all good so return the token
return response()->json(compact('token'));
}
Вы можете мне помочь? большое вам спасибо
Вы можете увидеть заголовки ваш браузер посылает, и есть что-то вроде: 'Авторизация: Bearer' + длинного ключа? –
Помогает ли это http://stackoverflow.com/questions/33101810/getting-token-not-provided-when-using-authorization-header-with-jwt-laravel – haakym