FOSOAuthServerBundle: Invalid grant_type parameter or parameter missing

missing form parameter: grant_type keycloak postman
missing grant_type parameter value postman
keycloak {"error":"invalid_request","error_description":"missing form parameter: grant_type"}
invalid grant_type=password
{ "error": "unsupported_grant_type", "error_description": "invalid grant_type: " }
invalid grant_type linkedin
errortype invalid_request message missing grant_type parameter value
missing or duplicate parameters

I'm trying to build a REST API using Symfony 3.1 and the FOSRestBundle, FOSUserBundle and FOSOAuthServerBundle. I managed to achieve this following the guide at https://gist.github.com/tjamps/11d617a4b318d65ca583.

I'm now struggling at the authentication process. When I make a POST request to the server for authentication (to localhost:8000/oauth/v2/token) with the parameters encoded in json in the request body:

{
    "grant_type": "password",
    "client_id": "1_myveryverysecretkey",
    "client_secret": "myveryverymostsecretkey",
    "username": "theuser",
    "password": "thepassword"
}

The additional HTTP Headers are the following:

Accept: application/json
Cache-Control: no-store, private
Connection: close
Content-Type: */json

The client in the db table oauth2_client has the "password" grant_type a:1:{i:0;s:8:"password";}, as suggested by the guide.

The server is accepting the request, but I always get the response

{"error":"invalid_request","error_description":"Invalid grant_type parameter or parameter missing"}

Any suggestions what I am missing? Thanks!

I had the same problem. It seems fosOAuthBundle is not accepting json. if you send the query with form fields, it will work.

FriendsOfSymfony/FOSOAuthServerBundle, error messages like : {"error":"invalid_request","error_description":"Invalid grant_type parameter or parameter missing"} Any idea , any help? Solved: I am using refresh token to automate updating of access and refresh tokens. It works pretty well. However, sometimes the access token renewal

This is because FOSRestBundle uses a body listener which converts underscored keys to camel case. So the parameters that your OAuth2 server gets are not grant_type, but rather grantType, which it cannot process and so it gives you that error.

A solution for this would be to use a custom array normalizer on the body listener of fos rest.

FOSOAuthServerBundle: Invalid grant_type parameter or - html, the response {"error":"invalid_request","error_description":"Invalid grant_type parameter or parameter missing"} Any suggestions what I am missing? Thanks! @wellington-cunha It's grant_type=authorization_code, not grant_type=auth_code. See RFC . Also, you're sending username / password which make no sense for that part of the authorization code flow.

really the FOSRestBundle Body Listener is the main 'cause' of this issue.

Array normalizer config

fos_rest:
    body_listener:
        array_normalizer: fos_rest.normalizer.camel_keys 

it converts _ to camel case format.

The solution was remove it of my configuration by the moment.

calling again /oauth/v2/token endpoint:

{
    "access_token": "NDBlZGViN2YwZGM5MTQ3ZTgwN2FhOGY4MDU4MTc1MTY2YzZmOThlMTdkM2JiZDJmMDVmNTg3MjU4N2JmODY3ZA",
    "expires_in": 3600,
    "token_type": "bearer",
    "scope": null,
    "refresh_token": "MDRiODllNjlhZWYxZjI5MjlhMzAxNGVhMDY5NjQxMmVmNDE5MzY3YzU0MGM0MDU1ZTVlY2Y2Zjg4ZTYyYzU3Mw"
}

always getting Invalid grant_type parameter or par, always getting Invalid grant_type parameter or parameter missing but works on postman. I am trying to get my access token with a post request. Our team is currently investigating the reports we are seeing around the invalid_request - missing grant type errors. One of the causes we've seen so far for this problem is setting the header "Content-Type: application/json", which is not supported.

Symfony a RESTFul app: Security ( FOSOAuthServerBundle , new FOS\OAuthServerBundle\FOSOAuthServerBundle(), it always return invalid grant_type or missing parameters {“error”:”invalid_request”  Dismiss Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Solved: OAuth2 access token request invalid, I am unsure what variable/data to use in this parameter. Reading the documentation, I noted that is the same value from code attribute: curl https://  always getting Invalid grant_type parameter or parameter missing but works on postman I am trying to get my access token with a post request. I have tried the request on postman and it works perfectly.

Box oauth2: Invalid grant_type parameter or parameter missing , Box oauth2: Invalid grant_type parameter or parameter missing. I don't know what I do wrong, but everytime I tried to obtain the token (after user authentication of  "error_description":"The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "grant_type" parameter."

Comments
  • Isn't there anyone who may have a hint?