0

I want to implement the function getRefreshToken with the oauth2-server module in Nodejs. I already implemented the whole password grant type successfull. But now I want to implement the refresh_token grant. I'm facing a problem by implementing the getRefreshToken function in the models.

If I call the refresh_token route with the grant_type: refresh_token and the refresh_token I'm getting back the error message:

"Invalid grant: refresh token is invalid".

I never check if the refreshToken is valid/expired or not. I just want to implement a dummy function which should return me a new accessToken.

What am I doing wrong?

getRefreshToken: (refreshToken, callback) => {
    const token = {
        refreshToken: refreshToken,
        client: 'client1',
        user: 'UserIdXY'
    }

    callback(false, token);
}
barbsan
  • 3,418
  • 11
  • 21
  • 28
Stack
  • 1
  • 2
  • According to [the docs](https://oauth2-server.readthedocs.io/en/latest/model/spec.html#getrefreshtoken-refreshtoken-callback) seems that `client` should be an object with property `id`, but I don't know if that's the case – barbsan May 31 '19 at 12:15
  • Jeah as simple as it is. Changed the client to an client object an added property id. It's working now. Thanks – Stack May 31 '19 at 12:32

1 Answers1

0

According to the docs you should change client: 'client1', to

client: {id: 'client1'},
barbsan
  • 3,418
  • 11
  • 21
  • 28