简体   繁体   English

Laravel 5.3 Passport 不起作用

[英]Laravel 5.3 Passport is not working

I am new in Laravel Passport and installed and configured with official documentation.我是 Laravel Passport 的新手,使用官方文档进行安装和配置。

public function register(){
    $password = Hash::make('demo');
    $user = DB::table('users')->insertGetId([
          'name'     => 'User',
          'email'    => 'userdev@gmail.com',
          'password' => $password,
        ]);

     // create oauth client
    $oauth_client = \App\OauthClient::create([
        'user_id'                => $user,
        'name'                   => 'User',
        'secret'                 => base64_encode(hash_hmac('sha256',$password, 'secret', true)),
        'password_client'        => 1,
        'personal_access_client' => 0,
        'redirect'               => '',
        'revoked'                => 0,
    ]);

    $response = ['status'=>200,'message'=>'Successfully Registered'];
    return $response;

I just run the API throgh postman and its getting response as Successfully Registered我只是通过邮递员运行 API 并获得成功注册的响应

After that I just called the http://localhost/passport/oauth/token route to authenticate the user.之后,我只是调用了http://localhost/passport/oauth/token路由来验证用户。 But its not working.但它不起作用。 Its returning like..它的返回就像..

Postdata :发布数据 :

grant_type:password
client_id :1
client_secret:j7q0ky8chHQ0RHJFpWo4Lqn/hl7Z0ntzYeyzsXE9ULA=
username:userdev@gmail.com
password:demo
scope:

Response :回应:

{
   "error": "invalid_request",
   "message": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.",
   "hint": "Check the `client_id` parameter"
} 

确保它放在 body 中而不是放在 params 中。

仍然不确定为什么,但是运行 php artisan config:clear 为我解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM