Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

different signatures in oauth.authorize #10

Open
midnightcodr opened this issue Oct 25, 2015 · 1 comment
Open

different signatures in oauth.authorize #10

midnightcodr opened this issue Oct 25, 2015 · 1 comment

Comments

@midnightcodr
Copy link

Hello,
In the example oauth.authorize is passed with two different signatures, the first one is (request, reply, function ... ) and the second one is (function ...), was that an error? Because when token() is called, the following error is raised:
TypeError: Uncaught error: Cannot read property 'lazy' of undefined

at Object.internals.convertToExpress (/path/to/node_modules/hapi-oauth2orize/index.js:202:20)

function authorize(request, reply) {
  oauth.authorize(request, reply, function (req, res) {
    reply.view('oauth', {transactionID: req.oauth2.transactionID});
  }, function (clientID, redirect, done) {
    server.helpers.find('client', clientID, function (docs) {
      done(null, docs[0], docs[0].redirect_uri);
    });
  });
};

function decision(request, reply) {
    oauth.decision(request, reply);
};

function token(request, reply) {
  oauth.authorize(function (clientID, redirect, done) {
    done(null, clientID, redirect);
  });
};

Also I wonder if it's possible to include authentication in the example. Should I use hapi-auth-cookie to handle authentication with oauth2orize?

@midnightcodr
Copy link
Author

I think I found the answer to my own question. The second oath.authorize should actually be oauth.token. I have forked this repo at https://github.com/midnightcodr/hapi-oauth2orize with a minor update to index.js and the example shown in README.md. This post https://hnryjms.github.io/2014/07/oauth2/ helped me a lot in figuring out the solution.

@devinivy
Copy link
Collaborator

devinivy commented Mar 7, 2016

Thanks! The docs need a lot of work, and we'd definitely take the help. Can you explain the change you made to index.js?

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

No branches or pull requests

2 participants