grails / grails-spring-security-rest

Grails plugin to implement token-based, RESTful authentication using Spring Security
http://alvarosanchez.github.io/grails-spring-security-rest/
Other
204 stars 114 forks source link

"Invalid grant_type" on refresh token #393

Closed florent-blanvillain closed 5 years ago

florent-blanvillain commented 5 years ago

Hello there,

And thank you very much Alvaro 👍 for your plugin I've been using for years now with an Ember.js app.

I'm on my way to upgrade both my backend (=>grails 3.3) and my frontend, anyway ; When the oauth/refresh_token is hit, I get a 400 http response code along with the text : Invalid grant_type

Any idea why ?

majkelo commented 5 years ago

Please check the code: https://github.com/alvarosanchez/grails-spring-security-rest/blob/ffa848c9c6dd82f92f2ab489cb5d7a1515c587f2/spring-security-rest/grails-app/controllers/grails/plugin/springsecurity/rest/RestOauthController.groovy#L123 You are providing wrong param when trying to refresh the token.

rafadalosto commented 5 years ago

Hi @florent-blanvillain probably the problem is your Content-type Header. It should be application/x-www-form-urlencoded

Follow a CURL example curl -X POST \ http://127.0.0.1:8080/oauth/access_token \ -H 'Content-Type: application/x-www-form-urlencoded' \ -d 'grant_type=refresh_token&refresh_token=REFRESH_TOKEN

florent-blanvillain commented 5 years ago

Thank you very much both of you, indeed it was an encoding issue. 👍