Search code examples
laravellaravel-passport

How to retrieve access token with passport in laravel?


I just followed the steps in Laravel official.
i'm using postman to send post request (http://localhost:7777/my-project/public/oauth/token ) so i can retrieve the access token:

{
  "grant_type" : "password",
  "client_id" : "2",
  "client_secret" : "oxKBv6EnyEXeF6l4FBbkVcLgq2WPnyB9EOdlUpL5",
  "username" : "my_email",
  "password" : "my_password",
  "scope" :""
}

i get this error:

{"error":"invalid_credentials","message":"The user credentials were incorrect."}

even though i'm sure my credentials are correct.


Solution

  • Your client must be setup as a password grant client to be able to use the password grant:

    https://laravel.com/docs/5.5/passport#creating-a-password-grant-client

    Normal clients do not have the password grant enabled.