0
votes

I try generate a access token in my application on WSO2 using implicit grant type, following the request:

POST /token HTTP/1.1
Host: localhost:8243
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
Postman-Token: d6ef6038-9860-bdc6-3867-70af98b37cc6

grant_type=code&response_type=implicit&client_id=CLIENT_ID&redirect_uri=http%3A%2F%2Flocalhost%3A8888%2Fplayground%2Foauth2client&scope=default

And the request return this error:

{
    "error_description": "Invalid grant_type parameter value",
    "error": "invalid_request"
}

This is my grant types settings:

Grant Types

Why this error happen, although the settings include the implicit grant type?

1

1 Answers

1
votes

I think you are mixing up few things. If you want to use the Implicit grant, you don't use the /token endpoint - you get everything from the authorization endpoint. The request could look like this:

/auth?response_type=token&client_id=...&redirect_uri=...

and after a successful authentication, the client gets an access token right away as part of the redirect URL.

If you have a code and you want to exchange it for an access token and a refresh token, you are using the Authorization code grant. Then the correct grant_type value is authorization_code and you must specify the code in the code URL parameter. So the error message you are getting is correct.

Finally, the token endpoint has no response_type parameter. It's a parameter of the authrization endpoint and the correct value for the implicit flow is token, because you want an access token to be returned.