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

bug into redis example #66

Open antoniosap opened 6 years ago

antoniosap commented 6 years ago

TypeError: expecting a function but got [object Object] on var db = require('bluebird').promisify(require('redis').createClient());

cryptiklemur commented 6 years ago

Redis example is also missing saveAuthorizationCode, and using the wrong package oauth2-server vs express-oauth-server, and not initializing the class.

antoniosap commented 6 years ago

and then ? trash everything ?

tobilg commented 6 years ago

Try using

const redis = require("redis");
const bluebird = require("bluebird");
bluebird.promisifyAll(redis.RedisClient.prototype);
const db = redis.createClient();

instead. I had the same error, and this fixed it.

moacode commented 6 years ago

I had a lot of issues with the Redis example. I've now implemented a fully working example of Redis, and am planning on issuing a pull request to update the example this week.

Rayan20 commented 4 years ago

Have you update the redis example? I still got missing client grants because this block of code: The client in the .then(function(client) is a boolean "true", so of course client.grants is undefined. return promisify(this.model.getClient, 2).call(this.model, credentials.clientId, credentials.clientSecret) .then(function(client) { if (!client) { throw new InvalidClientError('Invalid client: client is invalid'); }

  if (!client.grants) {
    throw new ServerError('Server error: missing client `grants`');
  }