我使用5.5 larevel的版本和邮递员来测试API。laravel护照密码授予未经身份验证
我跑的命令
PHP工匠护照:客户--password
要生成的ID和密码。当我发布localhost:8000/oauth/token
后:
它返回我一个令牌,但是当我想要得到的enpoints重视回报我未认证
这里是路线API .php
<?php
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::middleware('auth:api')->get('/users', function (Request $request) {
return $request->user();
});
Route::middleware('auth:api')->get('/subjects','[email protected]');
哪里是.htaccess文件。我的项目未在www/var/ –
中运行我添加了.htaccess并且没有功能 –
.htaccess文件应该位于公用文件夹内。矿看起来像这样:' 选项-MultiViews RewriteEngine叙述在 的RewriteCond%{HTTP:授权}(。*)。^ 重写规则* - 苯并[e = HTTP_AUTHORIZATION:%1] #重定向结尾的斜杠如果不是文件夹... 的RewriteCond%{REQUEST_FILENAME} -D- 重写规则^(。*)/ $/$ 1 [L,R = 301] #手柄前!控制器... RewriteCond%{REQUEST_FILENAME}!-d RewriteCond%{REQUEST_FILENAME}!-f RewriteRule^index.php [L] ' –