PHPclown

2600 经验值

没有通过验证,报404什么问题呢,如果通过验证的话就一切正常,不通过验证就是404,不是422

我现在也遇到这个问题了,能加个Q问下解决办法么... =.+

这是我的路由文件代码,用的是laravel 5.2版本:

Auth::loginUsingId(1);

Route::post('oauth/authorize', ['as' => 'oauth.authorize.post', 'middleware' => ['check-authorization-params', 'auth'], function() {

    $params = Authorizer::getAuthCodeRequestParams();
    $params['user_id'] = Auth::user()->id;
    $redirectUri = '/';

    // If the user has allowed the client to access its data, redirect back to the client with an auth code.
    if (Request::has('approve')) {
        $redirectUri = Authorizer::issueAuthCode('user', $params['user_id'], $params);
    }

    // If the user has denied the client to access its data, redirect back to the client with an error message.
    if (Request::has('deny')) {
        $redirectUri = Authorizer::authCodeRequestDeniedRedirectUri();
    }

    return Redirect::to($redirectUri);
}]);

Route::get('oauth/authorize', ['as' => 'oauth.authorize.get', 'middleware' => ['check-authorization-params'], function() {
   $authParams = Authorizer::getAuthCodeRequestParams();

   $formParams = array_except($authParams,'client');

   $formParams['client_id'] = $authParams['client']->getId();

   $formParams['scope'] = implode(config('oauth2.scope_delimiter'), array_map(function ($scope) {
       return $scope->getId();
   }, $authParams['scopes']));

   return view('oauth.authorization-form', ['params' => $formParams, 'client' => $authParams['client']]);
}]);

Route::post('oauth/access_token', function() {
    return Response::json(Authorizer::issueAccessToken());
});

JellyBool好,当我点击Approve后出现了这样的错误:

### ErrorException in AuthManager.php line 292:
call_user_func_array() expects parameter 1 to be a valid callback, class 'Illuminate\Auth\SessionGuard' does not have a method 'handle'

不好意思JellyBool,按照你说的还是没法解决,我写在有道笔记里,麻烦你了 http://note.youdao.com/noteshare?id=cf9cfe7c7f900c6f90ee0d5048fbdd34

检查了很多遍,还是没发现写错的地方:
<?php

namespace App\Api\Transformers;

use League\Fractal\TransformerAbstract;

class LessonTransformer extends TransformerAbstract
{

public function transform(Lesson $lesson)
{
    return [
        'title' => $lesson['title'],
        'content' => $lesson['body'],
        'is_free' => (boolean) $lesson['free']
    ];
}

}
?>

<?php

namespace App\Api\Controllers;

use App\Lesson;
use App\Api\Transformers\LessonTransformer;

class LessonsController extends BaseController{

public function index()
{
    // return Lesson::all();

    $lessons = Lesson::all();

    return $this->collection($lessons,new LessonTransformer());
}

}
?>

JellyBool好~ 当我做到最后字段映射的时候出现这样的错误
"message": "Argument 1 passed to App\\Api\\Transformers\\LessonTransformer::transform() must be an instance of App\\Api\\Transformers\\Lesson, instance of App\\Lesson given, called in D:\\xampp\\htdocs\\laravistapi\\vendor\\league\\fractal\\src\\Scope.php on line 373 and defined",
"status_code": 500,
"debug": {

"line": 9,
"file": "D:\\xampp\\htdocs\\laravistapi\\app\\Api\\Transformers\\LessonTransformer.php",
"class": "ErrorException",
"trace": [