1
これは重複しているようです。Auth :: user()がnullを返すLaravel 5.1 oauth 2.0
成功し取得した後、私は私の問題への解決策を見つけていない
- https://laracasts.com/discuss/channels/laravel/authuser-returns-null-in-laravel-52
- https://medium.com/@mshanak/laravel-5-token-based-authentication-ae258c12cfea#.8qeglhfnq
- Auth::user() returns null in Laravel 5.2
- Laravel : Auth::user() returns null
しかし:私はすでに、これらのスレッドをチェックしていますユーザのアクセストークンg認証情報Auth :: user()は、コントローラ内でnullを返します。
はここにここに私のroutes.php
Route::group(['prefix' => $api_prefix, 'middleware' => 'oauth', 'namespace' => 'Api'], function() {
Route::resource('user', 'UserController', ['except' => ['create', 'store']]);
Route::resource('post', 'PostController');
Route::post('follow/{user}', '[email protected]');
Route::post('unfollow/{user}', '[email protected]');
Route::post('trade/{user}', '[email protected]');
Route::post('untrade/{user}', '[email protected]');
Route::post('capturetime', '[email protected]');
がある私のKernel.php
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\LucaDegasperi\OAuth2Server\Middleware\OAuthExceptionHandlerMiddleware::class,
];
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'oauth' => \LucaDegasperi\OAuth2Server\Middleware\OAuthMiddleware::class,
'oauth-user' => \LucaDegasperi\OAuth2Server\Middleware\OAuthUserOwnerMiddleware::class,
'oauth-client' => \LucaDegasperi\OAuth2Server\Middleware\OAuthClientOwnerMiddleware::class,
'check-authorization-params' => \LucaDegasperi\OAuth2Server\Middleware\CheckAuthCodeRequestMiddleware::class,
'csrf' => \App\Http\Middleware\VerifyCsrfToken::class,
];
ある
});
すべてのヘルプは、ユーザーIDを取得するにはオーソ:: getResourceOwnerId()を使用する必要が