oauthjs / express-oauth-server

Complete, compliant and well tested module for implementing an OAuth2 Server/Provider with express in node.js
MIT License
484 stars 384 forks source link

Missing parameter 'accessToken' when invoking token() #96

Open kenanEkici opened 4 years ago

kenanEkici commented 4 years ago

I'm using token() with "password" as grant_type and am providing client, secret, username and password. The GetUser() of my model is able to retrieve and return the user. However, as a response I get "missing parameter 'accessToken'. It doesn't make sense to my why I should be providing accessToken when I'm clearly requesting for one?

eternal-scholar commented 2 years ago

I had the same issue. In my case the real error was printed in the terminal where the api was running and not in the output error in postman. "SequelizeValidationError: string violation: accessTokenExpiresAt cannot be an array or an object" it was caused by the fact that I had set accessTokenExpiresAt to string instead of date

jhunexjun commented 2 years ago

Is this fixed already? We have the same issues and actually encountered different issues but this is just one. To all the issues I encountered, I dealt it by making sure that all methods return should match the object structure the OAuth2.0 server is expecting in the model. Like:

function getRefreshToken(bearerToken) {
// more codes here
   return {
           refreshToken: result[0].refresh_token,
           refreshTokenExpiresAt: result[0].expires_at,
           // scope: result[0].scope,  // optional.
           client: { id: result[0].client_id }, // with 'id' property
           user: { id: result[0].user_id },
         };

You can add more as the docs says but the minimum should be met.