Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Passport - Grant Type Not Supported

I have installed Laravel Passport per the documentation and I have modified all areas of my code that is required.

I am working on setting up Password Grant Tokens so that users will be able to get an API token when logging in with their username and password for the site. I am hitting an issue though when it comes to the grant_type. For some reason Laravel is complaining about an invalid grant type.

{
  "error": "unsupported_grant_type",
  "message": "The authorization grant type is not supported by the authorization server.",
  "hint": "Check the `grant_type` parameter"
}

These are the fields that I am posting to /oauth/token

client_id = 4
client_secret = SMiYE7XqDNtXKQnmkYmFnXxfAaV83vRhnJ9zwCtZ
username = [email protected]
password = **************
grant_type = password
scope = *

I have run php artisan passport:install and I have also tried running php artisan passport:client --password

Both commands worked and both created the client and secrets, however, I cannot seem to get past the error about the grant_type.

Any suggestions on what I should look at to get this solved so that Password Grant Tokens will work for me?

like image 898
Joseph Crawford Avatar asked Dec 30 '16 15:12

Joseph Crawford


2 Answers

It appears that you must send the parameters as form data and not in the headers like I was doing... Rookie Mistake!

like image 196
Joseph Crawford Avatar answered Oct 15 '22 00:10

Joseph Crawford


I'm using Postman and I have put all parameters in Params. Postman shows the following response

{
    "error": "unsupported_grant_type",
    "message": "The authorization grant type is not supported by the authorization server.",
    "hint": "Check the `grant_type` parameter"
}

Now I put all parameters in Body and then press the Send button, It's working well.

like image 10
Muhammad Hashim Avatar answered Oct 15 '22 00:10

Muhammad Hashim