I read 本教程 http://blog.nedex.io/create-an-api-server-for-mobile-apps-using-laravel-5-1/我设法使它完美地工作。唯一的问题是当我从?令牌={token_here} to 授权持有者{此处为令牌}它停止工作。
我正在使用 Postman 并且正在写作授权在标题字段中和承载{空白}{令牌}在价值中。
我正在使用的库是https://github.com/tymondesigns/jwt-auth https://github.com/tymondesigns/jwt-auth
我在 Wiki 中读到了有关 Apache 问题的信息,但我不确定这是否是我的情况。我用PHP函数诊断了它获取所有标题() http://php.net/manual/pt_BR/function.getallheaders.php. If I 死亡并转储该函数表明授权标头可用。我尝试过使用和不使用 .htaccess 修改。
.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# RewriteCond %{HTTP:Authorization} ^(.)
# RewriteRule . - [e=HTTP_AUTHORIZATION:%1]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
路线文件
dd(getallheaders()['Authorization']);
Route::group(['prefix' => 'api'], function() {
Route::post('login', 'AuthenticateController@email');
Route::group(['middleware' => ['jwt.auth', 'jwt.refresh']], function() {
Route::post('logout', 'AuthenticateController@logout');
Route::get('test', function() {
return response()->json(['foo' => 'bar']);
});
});
});
对我哪里出错有什么想法吗?
Reminder: 如果我使用http://localhost/projects/linus/public/api/test?token= http://localhost/projects/linus/public/api/test?token={token}有用。