Skip to content

TypeError: Cannot read property 'set' of undefined #29

Open
@wehriam

Description

Version 2.4.0 of node-oauth2-server seems to have introduced a breaking change. I'll provide more information as soon as I can.

 TypeError: Cannot read property 'set' of undefined
      at Grant.sendResponse (/Users/johnwehr/Projects/test-project/node_modules/koa-oauth-server/node_modules/oauth2-server/lib/grant.js:471:5)
      at run (/Users/johnwehr/Projects/test-project/node_modules/koa-oauth-server/node_modules/oauth2-server/lib/runner.js:15:14)
      at /Users/johnwehr/Projects/test-project/node_modules/koa-oauth-server/node_modules/oauth2-server/lib/runner.js:17:7
      at Grant.saveRefreshToken (/Users/johnwehr/Projects/test-project/node_modules/koa-oauth-server/node_modules/oauth2-server/lib/grant.js:430:29)
      at run (/Users/johnwehr/Projects/test-project/node_modules/koa-oauth-server/node_modules/oauth2-server/lib/runner.js:15:14)
      at /Users/johnwehr/Projects/test-project/node_modules/koa-oauth-server/node_modules/oauth2-server/lib/runner.js:17:7
      at Grant.generateRefreshToken (/Users/johnwehr/Projects/test-project/node_modules/koa-oauth-server/node_modules/oauth2-server/lib/grant.js:412:66)
      at run (/Users/johnwehr/Projects/test-project/node_modules/koa-oauth-server/node_modules/oauth2-server/lib/runner.js:15:14)
      at /Users/johnwehr/Projects/test-project/node_modules/koa-oauth-server/node_modules/oauth2-server/lib/runner.js:17:7
      at /Users/johnwehr/Projects/test-project/node_modules/koa-oauth-server/node_modules/oauth2-server/lib/grant.js:401:5
      at /Users/johnwehr/Projects/test-project/models/oauth2-model.js:62:7

The offending function:

/**
 * Create an access token and save it with the model
 *
 * @param  {Function} done
 * @this   OAuth
 */
function sendResponse (done) {
  var response = {
    token_type: 'bearer',
    access_token: this.accessToken
  };

  if (this.config.accessTokenLifetime !== null) {
    response.expires_in = this.config.accessTokenLifetime;
  }

  if (this.refreshToken) response.refresh_token = this.refreshToken;

  this.res
    .set('Cache-Control', 'no-store') // Line 471
    .set('Pragma', 'no-cache')
    .jsonp(response);

  if (this.config.continueAfterResponse)
    done();
}

See the commit: thomseddon/node-oauth2-server@c19719e

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions