Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restify v5.x-compatible version? #47

Open
alexsk opened this issue Aug 8, 2017 · 1 comment
Open

Restify v5.x-compatible version? #47

alexsk opened this issue Aug 8, 2017 · 1 comment

Comments

@alexsk
Copy link

alexsk commented Aug 8, 2017

In Restify v5.x all errors definitions were moved into the separate repository: restify-errors.

As a result, restify-oauth2 code requires refactoring as described here: http://restify.com/docs/home/#restify-errors

@billchau
Copy link

billchau commented Sep 6, 2017

For example, the makeOAuthError.js file should be changed to the following.

"use strict";

var errors = require("restify-errors");

module.exports = function makeOAuthError(errorClass, errorType, errorDescription) {
    var body = { error: errorType, error_description: errorDescription };
    return new errors[errorClass + "Error"]({ message: errorDescription, body: body });
};

Moreover, the error response for the secret route in server.js should be the following

if (!req.username) {
    return res.send(new errors.UnauthorizedError("No allowed."));
//not return res.sendUnauthenticated();
}

PS. you need to import the "restify-errors" at the beginning of the file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants