getRefreshToken should return an object.
As I read through the docs at:
https://oauth2-server.readthedocs.io/en/latest/model/spec.html#getrefreshtoken-refreshtoken-callback
I see that this function is expected to return an object, however it can dispatch a callback, and along with the callback note there's a mention of a Promise.
Now an assumption: If we are to return a plain object, this is a pure function. I don't see how this could make sense.
If I return a Promise, the code never proceeds. I see the server actually call the function, but it does nothing with the returned Promise.
If I use the callback, it actually passes on and does something, however if I callback with the token I simply get a server_error: [object Object]. Now most likely this is because I'm dispatching an invalid refresh token back through the callback. I've trying A LOT of different things and combinatons but to no avail.
I am trying to callback with a refresh token that looks something like this:
{
refreshToken: '2ppf9bmufxliw9ncm4wz9elcnyka2opvlwj9ludu',
client: { id: '123' },
user: { id: 'some-user-id' }
}
I am a bit confused as I have no documentation as to how the callback parameters should look like, nor does the promise route seem to work.
Here's the full code I'm trying out at the moment:
model.getRefreshToken = async function(refreshToken, callback) {
console.log("in getRefreshToken (refreshToken: " + refreshToken + ")");
callback({
refreshToken: "2ppf9bmufxliw9ncm4wz9elcnyka2opvlwj9ludu",
client: { id: "123" },
user: { id: "some-user-id" }
});
return {
refreshToken: "2ppf9bmufxliw9ncm4wz9elcnyka2opvlwj9ludu",
client: { id: "123" },
user: { id: "some-user-id" }
};
I've tried with and without optional parameters as well, only with callback, only with Promise. Returning as plain object too. Everything results in a server_error.
Version: "oauth2-server": "^3.0.1"